新增完整换货生命周期管理:后台发起 → 客户端填收货信息 → 后台发货 → 确认完成(含可选全量迁移) → 旧资产转新再销售 后台接口(7个): - POST /api/admin/exchanges(发起换货) - GET /api/admin/exchanges(换货列表) - GET /api/admin/exchanges/:id(换货详情) - POST /api/admin/exchanges/:id/ship(发货) - POST /api/admin/exchanges/:id/complete(确认完成+可选迁移) - POST /api/admin/exchanges/:id/cancel(取消) - POST /api/admin/exchanges/:id/renew(旧资产转新) 客户端接口(2个): - GET /api/c/v1/exchange/pending(查询换货通知) - POST /api/c/v1/exchange/:id/shipping-info(填写收货信息) 核心能力: - ExchangeOrder 模型与状态机(1待填写→2待发货→3已发货→4已完成,1/2可取消→5) - 全量迁移事务(11张表:钱包、套餐、标签、客户绑定等) - 旧资产转新(generation+1、状态重置、新钱包、历史隔离) - 旧 CardReplacementRecord 表改名为 legacy,is_replaced 过滤改为查新表 - 数据库迁移:000085 新建 tb_exchange_order,000086 旧表改名
67 lines
2.1 KiB
Go
67 lines
2.1 KiB
Go
package routes
|
|
|
|
import (
|
|
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
|
"github.com/break/junhong_cmp_fiber/pkg/openapi"
|
|
"github.com/gofiber/fiber/v2"
|
|
)
|
|
|
|
func registerAdminExchangeRoutes(router fiber.Router, handler *admin.ExchangeHandler, doc *openapi.Generator, basePath string) {
|
|
Register(router, doc, basePath, "POST", "/exchanges", handler.Create, RouteSpec{
|
|
Summary: "创建换货单",
|
|
Tags: []string{"换货管理"},
|
|
Input: new(dto.CreateExchangeRequest),
|
|
Output: new(dto.ExchangeOrderResponse),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(router, doc, basePath, "GET", "/exchanges", handler.List, RouteSpec{
|
|
Summary: "获取换货单列表",
|
|
Tags: []string{"换货管理"},
|
|
Input: new(dto.ExchangeListRequest),
|
|
Output: new(dto.ExchangeListResponse),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(router, doc, basePath, "GET", "/exchanges/:id", handler.Get, RouteSpec{
|
|
Summary: "获取换货单详情",
|
|
Tags: []string{"换货管理"},
|
|
Input: new(dto.ExchangeIDRequest),
|
|
Output: new(dto.ExchangeOrderResponse),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(router, doc, basePath, "POST", "/exchanges/:id/ship", handler.Ship, RouteSpec{
|
|
Summary: "换货发货",
|
|
Tags: []string{"换货管理"},
|
|
Input: new(dto.ExchangeShipParams),
|
|
Output: new(dto.ExchangeOrderResponse),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(router, doc, basePath, "POST", "/exchanges/:id/complete", handler.Complete, RouteSpec{
|
|
Summary: "确认换货完成",
|
|
Tags: []string{"换货管理"},
|
|
Input: new(dto.ExchangeIDRequest),
|
|
Output: nil,
|
|
Auth: true,
|
|
})
|
|
|
|
Register(router, doc, basePath, "POST", "/exchanges/:id/cancel", handler.Cancel, RouteSpec{
|
|
Summary: "取消换货",
|
|
Tags: []string{"换货管理"},
|
|
Input: new(dto.ExchangeCancelParams),
|
|
Output: nil,
|
|
Auth: true,
|
|
})
|
|
|
|
Register(router, doc, basePath, "POST", "/exchanges/:id/renew", handler.Renew, RouteSpec{
|
|
Summary: "旧资产转新",
|
|
Tags: []string{"换货管理"},
|
|
Input: new(dto.ExchangeIDRequest),
|
|
Output: nil,
|
|
Auth: true,
|
|
})
|
|
}
|