feat:增加对增值服务的名称和类型筛选以及额度字段和是否过期作废字段展示
This commit is contained in:
parent
0c7f70af93
commit
1c148b0078
@ -115,9 +115,27 @@ func UpdateValueAddServiceLang(tx *gorm.DB, columns map[string]interface{}) (err
|
||||
// 增值套餐列表
|
||||
func ValueAddServiceList(req *bundle.ValueAddServiceListRequest) (res []*model.ValueAddService, total int64, err error) {
|
||||
query := app.ModuleClients.BundleDB.Model(&model.ValueAddService{}).
|
||||
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")
|
||||
Where("deleted_at = 0")
|
||||
|
||||
// 使用子查询筛选符合条件的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
|
||||
|
@ -340,6 +340,8 @@ func ValueAddServiceList(req *bundle.ValueAddServiceListRequest) (res *bundle.Va
|
||||
return res, errors.New("查询增值服务列表失败")
|
||||
}
|
||||
for _, valueAddService := range list {
|
||||
var quotaInfo string
|
||||
var isExpired bool
|
||||
serviceInfo := &bundle.ValueAddService{
|
||||
Uuid: valueAddService.UUID,
|
||||
ServiceName: valueAddService.ServiceName,
|
||||
@ -361,6 +363,25 @@ func ValueAddServiceList(req *bundle.ValueAddServiceListRequest) (res *bundle.Va
|
||||
QuotaValue: serviceLang.QuotaValue,
|
||||
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 {
|
||||
var options []*bundle.ValueAddPriceOptions
|
||||
for _, option := range serviceLang.Options {
|
||||
@ -389,6 +410,12 @@ func ValueAddServiceList(req *bundle.ValueAddServiceListRequest) (res *bundle.Va
|
||||
serviceLangInfo.Options = options
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
@ -501,8 +501,10 @@ message FinancialConfirmationRequest {
|
||||
message ValueAddService {
|
||||
string uuid = 1 [json_name = "uuid"];
|
||||
string serviceName = 2 [json_name = "serviceName"]; //服务名称
|
||||
int32 serviceType = 3 [json_name = "serviceType"];
|
||||
repeated ValueAddServiceLang serviceLang = 4 [json_name = "serviceLang"];
|
||||
int32 serviceType = 3 [json_name = "serviceType"]; //服务类型
|
||||
repeated ValueAddServiceLang serviceLang = 4 [json_name = "serviceLang"]; //不太语言的服务详细
|
||||
string serviceQuota = 5 [json_name = "serviceQuota"];//服务额度
|
||||
bool isExpired = 6 [json_name = "isExpired"];//是否过期作废
|
||||
}
|
||||
message ValueAddServiceLang {
|
||||
string uuid = 1 [json_name = "uuid"];
|
||||
@ -533,8 +535,9 @@ message ValueAddPriceOptions {
|
||||
message ValueAddServiceListRequest {
|
||||
int32 page = 1 [json_name = "page"];
|
||||
int32 pageSize = 2 [json_name = "pageSize"];
|
||||
string name = 3 [json_name = "name"];
|
||||
string language = 4 [json_name = "language"];
|
||||
string name = 3 [json_name = "name"]; // 服务名称
|
||||
int32 serviceType = 4 [json_name = "serviceType"]; // 服务类型
|
||||
string language = 5 [json_name = "language"]; // 语言(历史遗留,暂未使用)
|
||||
}
|
||||
message ValueAddServiceListResponse {
|
||||
int32 total = 1 [json_name = "total"];
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -7,8 +7,8 @@ import (
|
||||
fmt "fmt"
|
||||
math "math"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
_ "google.golang.org/protobuf/types/descriptorpb"
|
||||
_ "github.com/mwitkow/go-proto-validators"
|
||||
_ "google.golang.org/protobuf/types/descriptorpb"
|
||||
github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators"
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user