feat: 通用授权后台、离线证、Waffo 支付页与仪表盘加强
支持多产品计划展示、LICOFF 离线签发、支付独立配置与调试,以及分析看板;同步更新 README 与集成文档。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
0966375076
commit
8cc2c83f9d
41 files changed
+3177
-332
No files matched your search
@@ -46,7 +46,7 @@ func (s *PlanService) List(page, pageSize int, productID uint) ([]dto.PlanRespon
|
||||
// GetByProduct 查询某产品的上架计划(公开接口) // Logan.Li
|
||||
func (s *PlanService) GetByProduct(productID uint) ([]dto.PlanResponse, error) {
|
||||
var plans []model.Plan
|
||||
if err := s.db.Where("product_id = ? AND status = ?", productID, 1).
|
||||
if err := s.db.Preload("Product").Where("product_id = ? AND status = ?", productID, 1).
|
||||
Order("sort_order ASC").Find(&plans).Error; err != nil {
|
||||
return nil, errors.New("获取定价计划失败")
|
||||
}
|
||||
@@ -88,6 +88,7 @@ func (s *PlanService) Create(req dto.PlanCreate) (*dto.PlanResponse, error) {
|
||||
if err := s.db.Create(&plan).Error; err != nil {
|
||||
return nil, errors.New("创建定价计划失败")
|
||||
}
|
||||
plan.Product = product
|
||||
resp := toPlanResponse(plan)
|
||||
return &resp, nil
|
||||
}
|
||||
@@ -95,7 +96,7 @@ func (s *PlanService) Create(req dto.PlanCreate) (*dto.PlanResponse, error) {
|
||||
// Update 更新定价计划 // Logan.Li
|
||||
func (s *PlanService) Update(id uint, req dto.PlanUpdate) (*dto.PlanResponse, error) {
|
||||
var plan model.Plan
|
||||
if err := s.db.First(&plan, id).Error; err != nil {
|
||||
if err := s.db.Preload("Product").First(&plan, id).Error; err != nil {
|
||||
return nil, errors.New("定价计划不存在")
|
||||
}
|
||||
|
||||
@@ -128,7 +129,7 @@ func (s *PlanService) Update(id uint, req dto.PlanUpdate) (*dto.PlanResponse, er
|
||||
if err := s.db.Model(&plan).Updates(updates).Error; err != nil {
|
||||
return nil, errors.New("更新定价计划失败")
|
||||
}
|
||||
s.db.First(&plan, id)
|
||||
s.db.Preload("Product").First(&plan, id)
|
||||
resp := toPlanResponse(plan)
|
||||
return &resp, nil
|
||||
}
|
||||
@@ -146,16 +147,17 @@ func (s *PlanService) ToggleStatus(id uint, status int) error {
|
||||
// toPlanResponse 模型转响应 DTO // Logan.Li
|
||||
func toPlanResponse(p model.Plan) dto.PlanResponse {
|
||||
return dto.PlanResponse{
|
||||
ID: p.ID,
|
||||
ProductID: p.ProductID,
|
||||
Name: p.Name,
|
||||
PlanType: p.PlanType,
|
||||
Price: p.Price,
|
||||
Currency: p.Currency,
|
||||
Duration: p.Duration,
|
||||
MaxDevices: p.MaxDevices,
|
||||
Features: utils.ParseFeatures(p.Features),
|
||||
SortOrder: p.SortOrder,
|
||||
Status: p.Status,
|
||||
ID: p.ID,
|
||||
ProductID: p.ProductID,
|
||||
ProductName: p.Product.Name,
|
||||
Name: p.Name,
|
||||
PlanType: p.PlanType,
|
||||
Price: p.Price,
|
||||
Currency: p.Currency,
|
||||
Duration: p.Duration,
|
||||
MaxDevices: p.MaxDevices,
|
||||
Features: utils.ParseFeatures(p.Features),
|
||||
SortOrder: p.SortOrder,
|
||||
Status: p.Status,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user