fix 价格

This commit is contained in:
2025-12-26 14:43:22 +08:00
parent 9a578b4dc3
commit 55ab2e8018
11 changed files with 97 additions and 85 deletions

View File

@@ -29,8 +29,9 @@ func NewAdminCreateFeatureLogic(ctx context.Context, svcCtx *svc.ServiceContext)
func (l *AdminCreateFeatureLogic) AdminCreateFeature(req *types.AdminCreateFeatureReq) (resp *types.AdminCreateFeatureResp, err error) {
// 1. 数据转换
data := &model.Feature{
ApiId: req.ApiId,
Name: req.Name,
ApiId: req.ApiId,
Name: req.Name,
CostPrice: req.CostPrice,
}
// 2. 数据库操作

View File

@@ -38,6 +38,7 @@ func (l *AdminGetFeatureDetailLogic) AdminGetFeatureDetail(req *types.AdminGetFe
Id: record.Id,
ApiId: record.ApiId,
Name: record.Name,
CostPrice: record.CostPrice,
CreateTime: record.CreateTime.Format("2006-01-02 15:04:05"),
UpdateTime: record.UpdateTime.Format("2006-01-02 15:04:05"),
}

View File

@@ -54,6 +54,7 @@ func (l *AdminGetFeatureListLogic) AdminGetFeatureList(req *types.AdminGetFeatur
Name: item.Name,
CreateTime: item.CreateTime.Format("2006-01-02 15:04:05"),
UpdateTime: item.UpdateTime.Format("2006-01-02 15:04:05"),
CostPrice: item.CostPrice,
}
items = append(items, listItem)
}

View File

@@ -46,6 +46,9 @@ func (l *AdminUpdateFeatureLogic) AdminUpdateFeature(req *types.AdminUpdateFeatu
if req.Name != nil && *req.Name != "" {
record.Name = *req.Name
}
if req.CostPrice != nil {
record.CostPrice = *req.CostPrice
}
// 4. 执行更新操作
err = l.svcCtx.FeatureModel.UpdateWithVersion(l.ctx, nil, record)

View File

@@ -2,11 +2,11 @@ package admin_product
import (
"context"
"sync"
"tydata-server/app/main/api/internal/svc"
"tydata-server/app/main/api/internal/types"
"tydata-server/app/main/model"
"tydata-server/common/xerr"
"sync"
"github.com/pkg/errors"
"github.com/zeromicro/go-zero/core/logx"
@@ -146,6 +146,7 @@ func (l *AdminUpdateProductFeaturesLogic) AdminUpdateProductFeatures(req *types.
return updateErr
}
// 不自动更新产品成本价,保留用户手动设置的值
return nil
})
@@ -155,5 +156,7 @@ func (l *AdminUpdateProductFeaturesLogic) AdminUpdateProductFeatures(req *types.
}
// 5. 返回结果
return &types.AdminUpdateProductFeaturesResp{Success: true}, nil
return &types.AdminUpdateProductFeaturesResp{
Success: true,
}, nil
}

View File

@@ -2,10 +2,10 @@ package admin_product
import (
"context"
"database/sql"
"tydata-server/app/main/api/internal/svc"
"tydata-server/app/main/api/internal/types"
"tydata-server/common/xerr"
"database/sql"
"github.com/pkg/errors"
"github.com/zeromicro/go-zero/core/logx"

View File

@@ -21,9 +21,9 @@ type ServiceContext struct {
Redis *redis.Redis
// 中间件
AuthInterceptor rest.Middleware
UserAuthInterceptor rest.Middleware
AdminAuthInterceptor rest.Middleware
AuthInterceptor rest.Middleware
UserAuthInterceptor rest.Middleware
AdminAuthInterceptor rest.Middleware
// 用户相关模型
UserModel model.UserModel
@@ -80,8 +80,8 @@ type ServiceContext struct {
AdminPromotionOrderModel model.AdminPromotionOrderModel
// 其他模型
ExampleModel model.ExampleModel
GlobalNotificationsModel model.GlobalNotificationsModel
ExampleModel model.ExampleModel
GlobalNotificationsModel model.GlobalNotificationsModel
AuthorizationDocumentModel model.AuthorizationDocumentModel
// 服务
@@ -98,7 +98,6 @@ type ServiceContext struct {
AdminPromotionLinkStatsService *service.AdminPromotionLinkStatsService
ImageService *service.ImageService
AuthorizationService *service.AuthorizationService
}
// NewServiceContext 创建服务上下文
@@ -173,7 +172,6 @@ func NewServiceContext(c config.Config) *ServiceContext {
globalNotificationsModel := model.NewGlobalNotificationsModel(db, cacheConf)
authorizationDocumentModel := model.NewAuthorizationDocumentModel(db, cacheConf)
// ============================== 第三方服务初始化 ==============================
tianyuanapi, err := tianyuanapi.NewClient(tianyuanapi.Config{
AccessID: c.Tianyuanapi.AccessID,
@@ -220,9 +218,9 @@ func NewServiceContext(c config.Config) *ServiceContext {
return &ServiceContext{
Config: c,
Redis: redisClient,
AuthInterceptor: middleware.NewAuthInterceptorMiddleware(c).Handle,
UserAuthInterceptor: middleware.NewUserAuthInterceptorMiddleware().Handle,
AdminAuthInterceptor: middleware.NewAdminAuthInterceptorMiddleware(c,
AuthInterceptor: middleware.NewAuthInterceptorMiddleware(c).Handle,
UserAuthInterceptor: middleware.NewUserAuthInterceptorMiddleware().Handle,
AdminAuthInterceptor: middleware.NewAdminAuthInterceptorMiddleware(c,
adminUserModel, adminUserRoleModel, adminRoleModel, adminApiModel, adminRoleApiModel).Handle,
// 用户相关模型
@@ -280,8 +278,8 @@ func NewServiceContext(c config.Config) *ServiceContext {
AdminPromotionOrderModel: adminPromotionOrderModel,
// 其他模型
ExampleModel: exampleModel,
GlobalNotificationsModel: globalNotificationsModel,
ExampleModel: exampleModel,
GlobalNotificationsModel: globalNotificationsModel,
AuthorizationDocumentModel: authorizationDocumentModel,
// 服务
@@ -298,7 +296,6 @@ func NewServiceContext(c config.Config) *ServiceContext {
AdminPromotionLinkStatsService: adminPromotionLinkStatsService,
ImageService: imageService,
AuthorizationService: authorizationService,
}
}

View File

@@ -68,8 +68,9 @@ type AdminCreateApiResp struct {
}
type AdminCreateFeatureReq struct {
ApiId string `json:"api_id"` // API标识
Name string `json:"name"` // 描述
ApiId string `json:"api_id"` // API标识
Name string `json:"name"` // 描述
CostPrice float64 `json:"cost_price"` // 成本价
}
type AdminCreateFeatureResp struct {
@@ -363,11 +364,12 @@ type AdminGetFeatureDetailReq struct {
}
type AdminGetFeatureDetailResp struct {
Id int64 `json:"id"` // 功能ID
ApiId string `json:"api_id"` // API标识
Name string `json:"name"` // 描述
CreateTime string `json:"create_time"` // 创建时间
UpdateTime string `json:"update_time"` // 更新时间
Id int64 `json:"id"` // 功能ID
ApiId string `json:"api_id"` // API标识
Name string `json:"name"` // 描述
CostPrice float64 `json:"cost_price"` // 成本价
CreateTime string `json:"create_time"` // 创建时间
UpdateTime string `json:"update_time"` // 更新时间
}
type AdminGetFeatureExampleReq struct {
@@ -384,10 +386,11 @@ type AdminGetFeatureExampleResp struct {
}
type AdminGetFeatureListReq struct {
Page int64 `form:"page"` // 页码
PageSize int64 `form:"pageSize"` // 每页数量
ApiId *string `form:"api_id,optional"` // API标识
Name *string `form:"name,optional"` // 描述
Page int64 `form:"page"` // 页码
PageSize int64 `form:"pageSize"` // 每页数量
ApiId *string `form:"api_id,optional"` // API标识
Name *string `form:"name,optional"` // 描述
CostPrice *float64 `form:"cost_price,optional"` // 成本价
}
type AdminGetFeatureListResp struct {
@@ -754,9 +757,10 @@ type AdminUpdateApiResp struct {
}
type AdminUpdateFeatureReq struct {
Id int64 `path:"id"` // 功能ID
ApiId *string `json:"api_id,optional"` // API标识
Name *string `json:"name,optional"` // 描述
Id int64 `path:"id"` // 功能ID
ApiId *string `json:"api_id,optional"` // API标识
Name *string `json:"name,optional"` // 描述
CostPrice *float64 `json:"cost_price,optional"` // 成本价
}
type AdminUpdateFeatureResp struct {
@@ -1252,11 +1256,12 @@ type Feature struct {
}
type FeatureListItem struct {
Id int64 `json:"id"` // 功能ID
ApiId string `json:"api_id"` // API标识
Name string `json:"name"` // 描述
CreateTime string `json:"create_time"` // 创建时间
UpdateTime string `json:"update_time"` // 更新时间
Id int64 `json:"id"` // 功能ID
ApiId string `json:"api_id"` // API标识
Name string `json:"name"` // 描述
CostPrice float64 `json:"cost_price"` // 成本价
CreateTime string `json:"create_time"` // 创建时间
UpdateTime string `json:"update_time"` // 更新时间
}
type GetAgentPromotionQrcodeReq struct {