feat:增加对增值服务的名称和类型筛选以及额度字段和是否过期作废字段展示

This commit is contained in:
jiaji.H 2025-09-03 15:21:02 +08:00
parent 0c7f70af93
commit 1c148b0078
5 changed files with 959 additions and 880 deletions

View File

@ -115,10 +115,28 @@ func UpdateValueAddServiceLang(tx *gorm.DB, columns map[string]interface{}) (err
// 增值套餐列表 // 增值套餐列表
func ValueAddServiceList(req *bundle.ValueAddServiceListRequest) (res []*model.ValueAddService, total int64, err error) { func ValueAddServiceList(req *bundle.ValueAddServiceListRequest) (res []*model.ValueAddService, total int64, err error) {
query := app.ModuleClients.BundleDB.Model(&model.ValueAddService{}). query := app.ModuleClients.BundleDB.Model(&model.ValueAddService{}).
Where("deleted_at = 0"). Where("deleted_at = 0")
Preload("ValueAddServiceLang", func(db *gorm.DB) *gorm.DB {
return db.Select("uuid,service_name,service_type,price_mode,original_price,unit,language,price_type,options,created_at,updated_at") // 使用子查询筛选符合条件的UUID
}) if req.Name != "" || req.ServiceType != 0 {
subQuery := app.ModuleClients.BundleDB.Model(&model.ValueAddServiceLang{}).
Select("uuid").
Where("deleted_at = 0")
if req.Name != "" {
subQuery = subQuery.Where("service_name LIKE ?", "%"+req.Name+"%")
}
if req.ServiceType != 0 {
subQuery = subQuery.Where("service_type = ?", req.ServiceType)
}
query = query.Where("uuid IN (?)", subQuery)
}
// 预加载语言表数据
query = query.Preload("ValueAddServiceLang", func(db *gorm.DB) *gorm.DB {
return db.Select("uuid,service_name,service_type,price_mode,original_price,unit,language,price_type,options,created_at,updated_at,quota_type,quota_value,is_expired")
})
count := *query count := *query
if req.PageSize != 0 && req.Page != 0 { if req.PageSize != 0 && req.Page != 0 {

View File

@ -340,6 +340,8 @@ func ValueAddServiceList(req *bundle.ValueAddServiceListRequest) (res *bundle.Va
return res, errors.New("查询增值服务列表失败") return res, errors.New("查询增值服务列表失败")
} }
for _, valueAddService := range list { for _, valueAddService := range list {
var quotaInfo string
var isExpired bool
serviceInfo := &bundle.ValueAddService{ serviceInfo := &bundle.ValueAddService{
Uuid: valueAddService.UUID, Uuid: valueAddService.UUID,
ServiceName: valueAddService.ServiceName, ServiceName: valueAddService.ServiceName,
@ -361,6 +363,25 @@ func ValueAddServiceList(req *bundle.ValueAddServiceListRequest) (res *bundle.Va
QuotaValue: serviceLang.QuotaValue, QuotaValue: serviceLang.QuotaValue,
IsExpired: serviceLang.IsExpired, IsExpired: serviceLang.IsExpired,
} }
if serviceLangInfo.Language == "zh-CN" {
switch serviceLangInfo.QuotaType {
case 0:
quotaInfo = "不限额度"
case 1:
quotaInfo = fmt.Sprintf("每天%d个", serviceLangInfo.QuotaValue)
case 2:
quotaInfo = fmt.Sprintf("每月%d个", serviceLangInfo.QuotaValue)
case 3:
quotaInfo = fmt.Sprintf("每季度%d个", serviceLangInfo.QuotaValue)
case 4:
quotaInfo = fmt.Sprintf("每半年%d个", serviceLangInfo.QuotaValue)
case 5:
quotaInfo = fmt.Sprintf("每年%d个", serviceLangInfo.QuotaValue)
default:
quotaInfo = "不限额度"
}
isExpired = serviceLangInfo.IsExpired
}
if len(serviceLang.Options) > 0 { if len(serviceLang.Options) > 0 {
var options []*bundle.ValueAddPriceOptions var options []*bundle.ValueAddPriceOptions
for _, option := range serviceLang.Options { for _, option := range serviceLang.Options {
@ -389,6 +410,12 @@ func ValueAddServiceList(req *bundle.ValueAddServiceListRequest) (res *bundle.Va
serviceLangInfo.Options = options serviceLangInfo.Options = options
} }
serviceInfo.ServiceLang = append(serviceInfo.ServiceLang, serviceLangInfo) serviceInfo.ServiceLang = append(serviceInfo.ServiceLang, serviceLangInfo)
if quotaInfo != "" {
serviceInfo.ServiceQuota = quotaInfo
serviceInfo.IsExpired = isExpired
} else {
return res, errors.New("额度信息获取错误")
}
} }
res.ValueAddServiceList = append(res.ValueAddServiceList, serviceInfo) res.ValueAddServiceList = append(res.ValueAddServiceList, serviceInfo)
} }

View File

@ -501,8 +501,10 @@ message FinancialConfirmationRequest {
message ValueAddService { message ValueAddService {
string uuid = 1 [json_name = "uuid"]; string uuid = 1 [json_name = "uuid"];
string serviceName = 2 [json_name = "serviceName"]; // string serviceName = 2 [json_name = "serviceName"]; //
int32 serviceType = 3 [json_name = "serviceType"]; int32 serviceType = 3 [json_name = "serviceType"]; //
repeated ValueAddServiceLang serviceLang = 4 [json_name = "serviceLang"]; repeated ValueAddServiceLang serviceLang = 4 [json_name = "serviceLang"]; //
string serviceQuota = 5 [json_name = "serviceQuota"];//
bool isExpired = 6 [json_name = "isExpired"];//
} }
message ValueAddServiceLang { message ValueAddServiceLang {
string uuid = 1 [json_name = "uuid"]; string uuid = 1 [json_name = "uuid"];
@ -533,8 +535,9 @@ message ValueAddPriceOptions {
message ValueAddServiceListRequest { message ValueAddServiceListRequest {
int32 page = 1 [json_name = "page"]; int32 page = 1 [json_name = "page"];
int32 pageSize = 2 [json_name = "pageSize"]; int32 pageSize = 2 [json_name = "pageSize"];
string name = 3 [json_name = "name"]; string name = 3 [json_name = "name"]; //
string language = 4 [json_name = "language"]; int32 serviceType = 4 [json_name = "serviceType"]; //
string language = 5 [json_name = "language"]; // (使)
} }
message ValueAddServiceListResponse { message ValueAddServiceListResponse {
int32 total = 1 [json_name = "total"]; int32 total = 1 [json_name = "total"];

File diff suppressed because it is too large Load Diff

View File

@ -7,8 +7,8 @@ import (
fmt "fmt" fmt "fmt"
math "math" math "math"
proto "github.com/golang/protobuf/proto" proto "github.com/golang/protobuf/proto"
_ "google.golang.org/protobuf/types/descriptorpb"
_ "github.com/mwitkow/go-proto-validators" _ "github.com/mwitkow/go-proto-validators"
_ "google.golang.org/protobuf/types/descriptorpb"
github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators" github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators"
) )