Compare commits
26 Commits
main
...
feat-hjj-p
Author | SHA1 | Date | |
---|---|---|---|
|
f1b0c0d388 | ||
|
d915175416 | ||
|
2fd0f940a0 | ||
|
62755cc884 | ||
|
91fa9afa58 | ||
|
5f4e1610d3 | ||
|
5fd972942b | ||
|
2fc46f8bb7 | ||
|
1b9a64068a | ||
|
7edef20a45 | ||
|
75de934c4f | ||
|
7c08286128 | ||
|
e406bcc63a | ||
|
51f1c674fa | ||
|
66c2669557 | ||
|
9635ec4572 | ||
|
4d42019882 | ||
|
2461bb8a93 | ||
|
2280cc40d9 | ||
|
7741a5dc35 | ||
|
04b4b3f7c5 | ||
|
4b999f57c4 | ||
|
1624992428 | ||
|
c1e1ef5e0f | ||
|
1c148b0078 | ||
|
0c7f70af93 |
36
.gitignore
vendored
36
.gitignore
vendored
@ -1,36 +0,0 @@
|
|||||||
# local env files
|
|
||||||
.env.local
|
|
||||||
.env.*.local
|
|
||||||
|
|
||||||
# Log files
|
|
||||||
*.log
|
|
||||||
|
|
||||||
.idea
|
|
||||||
.vscode
|
|
||||||
*.suo
|
|
||||||
*.ntvs*
|
|
||||||
*.njsproj
|
|
||||||
*.sln
|
|
||||||
*.sw?
|
|
||||||
|
|
||||||
*.iml
|
|
||||||
# Binaries for programs and plugins
|
|
||||||
*.exe
|
|
||||||
*.exe~
|
|
||||||
*.dll
|
|
||||||
*.so
|
|
||||||
*.dylib
|
|
||||||
|
|
||||||
# Test binary, built with `go test -c`
|
|
||||||
*.test
|
|
||||||
|
|
||||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
|
||||||
*.out
|
|
||||||
|
|
||||||
/cmd/runtime
|
|
||||||
/cmd/logs/*.log
|
|
||||||
/cmd/runtime/log/*.log
|
|
||||||
/build/*
|
|
||||||
.vscode
|
|
||||||
.idea/*
|
|
||||||
/.idea/*
|
|
33
.vscode/launch.json
vendored
Normal file
33
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
// 使用 IntelliSense 了解相关属性。
|
||||||
|
// 悬停以查看现有属性的描述。
|
||||||
|
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Launch Package",
|
||||||
|
"type": "go",
|
||||||
|
"request": "launch",
|
||||||
|
"mode": "auto",
|
||||||
|
"env": {
|
||||||
|
"GOPATH":"C:\\Users\\lenovo\\go",
|
||||||
|
"GOOS":"windows"
|
||||||
|
},
|
||||||
|
"program": "${workspaceFolder}\\cmd",
|
||||||
|
"args":[]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Run app.go",
|
||||||
|
"type": "go",
|
||||||
|
"request": "launch",
|
||||||
|
"mode": "debug",
|
||||||
|
"program": "${workspaceFolder}/cmd",
|
||||||
|
"cwd": "${workspaceFolder}/cmd",
|
||||||
|
"env": {
|
||||||
|
"DEBUG": "true",
|
||||||
|
"DUBBO_GO_CONFIG_PATH": "${workspaceFolder}/conf/dubbogo.yaml"
|
||||||
|
},
|
||||||
|
"dlvFlags": ["--check-go-version=false"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
22
.vscode/settings.json
vendored
Normal file
22
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"workbench.colorCustomizations": {
|
||||||
|
"activityBar.activeBackground": "#fa1b49",
|
||||||
|
"activityBar.background": "#fa1b49",
|
||||||
|
"activityBar.foreground": "#e7e7e7",
|
||||||
|
"activityBar.inactiveForeground": "#e7e7e799",
|
||||||
|
"activityBarBadge.background": "#155e02",
|
||||||
|
"activityBarBadge.foreground": "#e7e7e7",
|
||||||
|
"commandCenter.border": "#e7e7e799",
|
||||||
|
"sash.hoverBorder": "#fa1b49",
|
||||||
|
"statusBar.background": "#dd0531",
|
||||||
|
"statusBar.foreground": "#e7e7e7",
|
||||||
|
"statusBarItem.hoverBackground": "#fa1b49",
|
||||||
|
"statusBarItem.remoteBackground": "#dd0531",
|
||||||
|
"statusBarItem.remoteForeground": "#e7e7e7",
|
||||||
|
"titleBar.activeBackground": "#dd0531",
|
||||||
|
"titleBar.activeForeground": "#e7e7e7",
|
||||||
|
"titleBar.inactiveBackground": "#dd053199",
|
||||||
|
"titleBar.inactiveForeground": "#e7e7e799"
|
||||||
|
},
|
||||||
|
"peacock.color": "#dd0531"
|
||||||
|
}
|
@ -135,23 +135,27 @@ func BundleListV2(req *bundle.BundleListRequest) (res *bundle.BundleListResponse
|
|||||||
res.Bundles = make([]*bundle.BundleProfile, 0)
|
res.Bundles = make([]*bundle.BundleProfile, 0)
|
||||||
bundles := make([]*model.BundleProfile, 0)
|
bundles := make([]*model.BundleProfile, 0)
|
||||||
|
|
||||||
query := app.ModuleClients.BundleDB.Model(&model.BundleProfile{}).Preload("BundleProfileLang")
|
baseQuery := app.ModuleClients.BundleDB.Model(&model.BundleProfile{})
|
||||||
|
|
||||||
if req.Name != "" {
|
if req.Name != "" {
|
||||||
query = query.Where("name like ?", "%"+req.Name+"%")
|
baseQuery = baseQuery.Where("name like ?", "%"+req.Name+"%")
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Content != "" {
|
if req.Content != "" {
|
||||||
query = query.Where("content like ?", "%"+req.Content+"%")
|
baseQuery = baseQuery.Where("content like ?", "%"+req.Content+"%")
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Language != "" {
|
if req.Language != "" {
|
||||||
query = query.Where("language like ?", req.Language)
|
baseQuery = baseQuery.Where("language like ?", req.Language)
|
||||||
}
|
}
|
||||||
|
|
||||||
count := *query
|
var total int64
|
||||||
|
if err = baseQuery.Count(&total).Error; err != nil {
|
||||||
|
return res, commonErr.ReturnError(err, msg.ErrorGetBundleList, "获取套餐总数失败: ")
|
||||||
|
}
|
||||||
|
|
||||||
// 排序:sort 升序,相同 sort 按 created_at 倒序
|
// 排序:sort 升序,相同 sort 按 created_at 倒序
|
||||||
|
query := baseQuery.Preload("BundleProfileLang")
|
||||||
query = query.Order("sort ASC").Order("created_at DESC")
|
query = query.Order("sort ASC").Order("created_at DESC")
|
||||||
if req.PageSize != 0 && req.Page != 0 {
|
if req.PageSize != 0 && req.Page != 0 {
|
||||||
query = query.Limit(int(req.PageSize)).Offset(int(req.Page-1) * int(req.PageSize))
|
query = query.Limit(int(req.PageSize)).Offset(int(req.Page-1) * int(req.PageSize))
|
||||||
@ -163,12 +167,23 @@ func BundleListV2(req *bundle.BundleListRequest) (res *bundle.BundleListResponse
|
|||||||
if len(bundles) > 0 {
|
if len(bundles) > 0 {
|
||||||
for _, bundleProfile := range bundles {
|
for _, bundleProfile := range bundles {
|
||||||
selectValueAddService := make([]*bundle.SelectValueAddService, 0)
|
selectValueAddService := make([]*bundle.SelectValueAddService, 0)
|
||||||
|
SelectValueAdditionalService := make([]*bundle.SelectValueAdditionalService, 0)
|
||||||
if bundleProfile.BundleToValueAddService != nil {
|
if bundleProfile.BundleToValueAddService != nil {
|
||||||
for _, v := range bundleProfile.BundleToValueAddService {
|
for _, v := range bundleProfile.BundleToValueAddService {
|
||||||
selectValueAddService = append(selectValueAddService, &bundle.SelectValueAddService{
|
//根据权益类型存入对应的list
|
||||||
ValueAddUuid: v.ValueUid,
|
switch v.BenefitsType {
|
||||||
IsDisplay: v.IsDisplay,
|
case msg.Benefits:
|
||||||
})
|
selectValueAddService = append(selectValueAddService, &bundle.SelectValueAddService{
|
||||||
|
ValueAddUuid: v.ValueUid,
|
||||||
|
IsDisplay: v.IsDisplay,
|
||||||
|
})
|
||||||
|
case msg.OptionalBenefits:
|
||||||
|
SelectValueAdditionalService = append(SelectValueAdditionalService, &bundle.SelectValueAdditionalService{
|
||||||
|
ValueAddUuid: v.ValueUid,
|
||||||
|
IsDisplay: v.IsDisplay,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bundleProfileLang := []*bundle.BundleProfileLang{}
|
bundleProfileLang := []*bundle.BundleProfileLang{}
|
||||||
@ -188,33 +203,30 @@ func BundleListV2(req *bundle.BundleListRequest) (res *bundle.BundleListResponse
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
res.Bundles = append(res.Bundles, &bundle.BundleProfile{
|
res.Bundles = append(res.Bundles, &bundle.BundleProfile{
|
||||||
Uuid: bundleProfile.UUID,
|
Uuid: bundleProfile.UUID,
|
||||||
Name: bundleProfile.Name,
|
Name: bundleProfile.Name,
|
||||||
Content: bundleProfile.Content,
|
Content: bundleProfile.Content,
|
||||||
Price: bundleProfile.Price,
|
Price: bundleProfile.Price,
|
||||||
PriceType: bundleProfile.PriceType,
|
PriceType: bundleProfile.PriceType,
|
||||||
Contract: bundleProfile.Contract,
|
Contract: bundleProfile.Contract,
|
||||||
Language: bundleProfile.Language,
|
Language: bundleProfile.Language,
|
||||||
CreatedAt: bundleProfile.CreatedAt.Format("2006-01-02 15:04:05"),
|
CreatedAt: bundleProfile.CreatedAt.Format("2006-01-02 15:04:05"),
|
||||||
UpdatedAt: bundleProfile.UpdatedAt.Format("2006-01-02 15:04:05"),
|
UpdatedAt: bundleProfile.UpdatedAt.Format("2006-01-02 15:04:05"),
|
||||||
CompanySign: bundleProfile.CompanySign,
|
CompanySign: bundleProfile.CompanySign,
|
||||||
ContractDuration: int64(bundleProfile.ContractDuration),
|
ContractDuration: int64(bundleProfile.ContractDuration),
|
||||||
Sort: bundleProfile.Sort,
|
Sort: bundleProfile.Sort,
|
||||||
ImgOption: int32(bundleProfile.ImgOption),
|
ImgOption: int32(bundleProfile.ImgOption),
|
||||||
BgImg1: bundleProfile.BgImg1,
|
BgImg1: bundleProfile.BgImg1,
|
||||||
BgImg2: bundleProfile.BgImg2,
|
BgImg2: bundleProfile.BgImg2,
|
||||||
SelectValueAddService: selectValueAddService,
|
SelectValueAddService: selectValueAddService,
|
||||||
BundleProfileLang: bundleProfileLang,
|
SelectValueAdditionalService: SelectValueAdditionalService,
|
||||||
ShelfStatus: int64(bundleProfile.ShelfStatus),
|
BundleProfileLang: bundleProfileLang,
|
||||||
FontColor: bundleProfile.FontColor,
|
ShelfStatus: int64(bundleProfile.ShelfStatus),
|
||||||
|
FontColor: bundleProfile.FontColor,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var total int64
|
|
||||||
|
|
||||||
count.Count(&total)
|
|
||||||
|
|
||||||
res.Total = int32(total)
|
res.Total = int32(total)
|
||||||
|
|
||||||
return
|
return
|
||||||
@ -322,6 +334,12 @@ func GetValueAddServiceUuidsByBundleUuid(bundleUuid string) ([]string, error) {
|
|||||||
return uuids, err
|
return uuids, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetValueAddServiceUuidsByAndBenefitsBundleUuid(bundleUuid string) ([]*model.ValueUidWithBenefits, error) {
|
||||||
|
var result []*model.ValueUidWithBenefits
|
||||||
|
err := app.ModuleClients.BundleDB.Model(&model.BundleToValueAddService{}).Select("value_uid, benefits_type").Where("bundle_uuid = ? and deleted_at = 0", bundleUuid).Scan(&result).Error
|
||||||
|
return result, err
|
||||||
|
}
|
||||||
|
|
||||||
// GetBundleToValueAddServiceByBundleUuid 根据套餐UUID获取所有关联的增值服务uuid
|
// GetBundleToValueAddServiceByBundleUuid 根据套餐UUID获取所有关联的增值服务uuid
|
||||||
func GetBundleToValueAddServiceByBundleUuid(bundleUuid string) ([]*model.BundleToValueAddService, error) {
|
func GetBundleToValueAddServiceByBundleUuid(bundleUuid string) ([]*model.BundleToValueAddService, error) {
|
||||||
var result []*model.BundleToValueAddService
|
var result []*model.BundleToValueAddService
|
||||||
|
@ -218,46 +218,39 @@ func CreateBundleBalance(data model.BundleBalance) error {
|
|||||||
return app.ModuleClients.BundleDB.Create(&data).Error
|
return app.ModuleClients.BundleDB.Create(&data).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetUsedRecord(req *bundle.GetUsedRecordListReq) (data []model.CostLogPo, total int64, err error) {
|
func GetUsedRecord(req *bundle.GetUsedRecordListReq) (data []model.CostLog, total int64, err error) {
|
||||||
session := app.ModuleClients.BundleDB.
|
session := app.ModuleClients.BundleDB.Model(&model.CostLog{})
|
||||||
Table("cast_cost_log ccl").
|
if req.Title != "" {
|
||||||
Select("ccl.*,cwl.cost_type").
|
session = session.Where("title = ?", req.Title)
|
||||||
Joins("left join cast_work_log cwl on cwl.work_uuid = ccl.work_uuid").
|
|
||||||
Where("cwl.work_status = 1 and cwl.deleted_at = 0 and ccl.deleted_at = 0")
|
|
||||||
if req.WorkTitle != "" {
|
|
||||||
session = session.Where("ccl.work_title like ?", "%"+req.WorkTitle+"%")
|
|
||||||
}
|
}
|
||||||
if req.Platform != 0 {
|
if req.Platform != 0 {
|
||||||
session = session.Where(fmt.Sprintf("JSON_CONTAINS(ccl.platform_ids,'%d')", req.Platform))
|
session = session.Where(fmt.Sprintf("JSON_CONTAINS(platform_ids,'%d')", req.Platform))
|
||||||
}
|
}
|
||||||
if req.Account != "" {
|
if req.Account != "" {
|
||||||
session = session.Where(fmt.Sprintf(`JSON_CONTAINS(ccl.media_names,'"%s"')`, req.Account))
|
session = session.Where(fmt.Sprintf(`JSON_CONTAINS(media_names,'"%s"')`, req.Account))
|
||||||
}
|
}
|
||||||
if req.SubmitTimeEnd != 0 {
|
if req.SubmitTimeEnd != 0 {
|
||||||
session = session.Where("ccl.submit_time <= ?", time.UnixMilli(req.SubmitTimeEnd))
|
session = session.Where("submit_time <= ?", time.UnixMilli(req.SubmitTimeEnd))
|
||||||
}
|
}
|
||||||
if req.SubmitTimeStart != 0 {
|
if req.SubmitTimeStart != 0 {
|
||||||
session = session.Where("ccl.submit_time >= ?", time.UnixMilli(req.SubmitTimeStart))
|
session = session.Where("submit_time >= ?", time.UnixMilli(req.SubmitTimeStart))
|
||||||
}
|
|
||||||
if req.CostType != 0 {
|
|
||||||
session = session.Where("cwl.cost_type = ?", req.CostType)
|
|
||||||
}
|
}
|
||||||
if req.User != "" {
|
if req.User != "" {
|
||||||
if utils.IsPhoneNumber(req.User) {
|
if utils.IsPhoneNumber(req.User) {
|
||||||
session = session.Where("ccl.artist_phone = ?", req.User)
|
session = session.Where("artist_phone = ?", req.User)
|
||||||
} else {
|
} else {
|
||||||
session = session.Where("ccl.artist_name like ?", "%"+req.User+"%")
|
session = session.Where("artist_name like ?", "%"+req.User+"%")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if req.Operator != "" {
|
if req.Operator != "" {
|
||||||
if utils.IsPhoneNumber(req.Operator) {
|
if utils.IsPhoneNumber(req.Operator) {
|
||||||
session = session.Where("ccl.operator_phone = ?", req.Operator)
|
session = session.Where("operator_phone = ?", req.Operator)
|
||||||
} else {
|
} else {
|
||||||
session = session.Where("ccl.operator_name like ?", "%"+req.Operator+"%")
|
session = session.Where("operator_name like ?", "%"+req.Operator+"%")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if req.Type != 0 {
|
if req.Type != 0 {
|
||||||
session = session.Where("ccl.work_category = ?", req.Type)
|
session = session.Where("work_category = ?", req.Type)
|
||||||
}
|
}
|
||||||
if err = session.Count(&total).Error; err != nil {
|
if err = session.Count(&total).Error; err != nil {
|
||||||
return
|
return
|
||||||
@ -265,7 +258,7 @@ func GetUsedRecord(req *bundle.GetUsedRecordListReq) (data []model.CostLogPo, to
|
|||||||
if req.Page != 0 && req.PageSize != 0 {
|
if req.Page != 0 && req.PageSize != 0 {
|
||||||
session = session.Offset(int(req.Page-1) * int(req.PageSize)).Limit(int(req.PageSize))
|
session = session.Offset(int(req.Page-1) * int(req.PageSize)).Limit(int(req.PageSize))
|
||||||
}
|
}
|
||||||
err = session.Order("ccl.updated_at desc").Find(&data).Error
|
err = session.Order("updated_at desc").Find(&data).Error
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,6 +103,8 @@ func UpdateValueAddService(tx *gorm.DB, columns map[string]interface{}) (err err
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 更新单个语言表
|
||||||
func UpdateValueAddServiceLang(tx *gorm.DB, columns map[string]interface{}) (err error) {
|
func UpdateValueAddServiceLang(tx *gorm.DB, columns map[string]interface{}) (err error) {
|
||||||
err = tx.Model(&model.ValueAddServiceLang{}).Where("uuid =? and deleted_at = 0", columns["uuid"]).
|
err = tx.Model(&model.ValueAddServiceLang{}).Where("uuid =? and deleted_at = 0", columns["uuid"]).
|
||||||
Where("language = ?", columns["language"]).Updates(columns).Error
|
Where("language = ?", columns["language"]).Updates(columns).Error
|
||||||
@ -112,13 +114,41 @@ func UpdateValueAddServiceLang(tx *gorm.DB, columns map[string]interface{}) (err
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 更新所有语言版本的服务类型
|
||||||
|
func UpdateAllValueAddServiceLangServiceType(tx *gorm.DB, columns map[string]interface{}) (err error) {
|
||||||
|
err = tx.Model(&model.ValueAddServiceLang{}).Where("uuid = ? and deleted_at = 0", columns["uuid"]).
|
||||||
|
Updates(columns).Error
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 增值套餐列表
|
// 增值套餐列表
|
||||||
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 {
|
||||||
@ -203,3 +233,78 @@ func BatchGetValueAddServiceLang(uuids []string, language string) (map[string]*m
|
|||||||
}
|
}
|
||||||
return resultMap, nil
|
return resultMap, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 判断套餐额度添加是否合理
|
||||||
|
func ValidateQuotaCompatibility(benefitsQuota, optionalQuota model.QuotaInfo) bool {
|
||||||
|
// 如果套餐权益是不限额度,则附加权益可以是任意额度
|
||||||
|
if benefitsQuota.QuotaType == 1 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果附加权益是不限额度,则套餐权益可以是任意额度
|
||||||
|
if optionalQuota.QuotaType == 1 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果都是限制额度,则额度值必须相同
|
||||||
|
return benefitsQuota.QuotaValue == optionalQuota.QuotaValue
|
||||||
|
}
|
||||||
|
|
||||||
|
// getServiceQuotaMap 获取服务类型的额度映射
|
||||||
|
func GetServiceQuotaMap(services []*model.BundleToValueAddService, serviceDetails map[string]*model.ValueAddServiceLang) map[int32]model.QuotaInfo {
|
||||||
|
quotaMap := make(map[int32]model.QuotaInfo)
|
||||||
|
|
||||||
|
for _, service := range services {
|
||||||
|
if detail, exists := serviceDetails[service.ValueUid]; exists {
|
||||||
|
quotaMap[int32(detail.ServiceType)] = model.QuotaInfo{
|
||||||
|
QuotaType: detail.QuotaType,
|
||||||
|
QuotaValue: detail.QuotaValue,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return quotaMap
|
||||||
|
}
|
||||||
|
|
||||||
|
// 通过增值服务uuid列表批量检查对应增值服务是否有默认套餐数量
|
||||||
|
func CheckDefaultServiceValueWithUid(uuids []string, language string) (uidList []string, unDefaultServiceNameList []string, err error) {
|
||||||
|
//为空直接返回
|
||||||
|
if len(uuids) == 0 {
|
||||||
|
return []string{}, []string{}, nil
|
||||||
|
}
|
||||||
|
// 1. 批量查询所有增值服务
|
||||||
|
var results []*model.ValueAddServiceLang
|
||||||
|
err = app.ModuleClients.BundleDB.
|
||||||
|
Where("uuid IN ? AND language = ? AND deleted_at = 0", uuids, language).
|
||||||
|
Find(&results).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, fmt.Errorf("批量查询增值服务语言失败: %w", err)
|
||||||
|
}
|
||||||
|
// 2. 构建UUID到服务的映射
|
||||||
|
serviceMap := make(map[string]*model.ValueAddServiceLang, len(results))
|
||||||
|
for _, result := range results {
|
||||||
|
serviceMap[result.UUID] = result
|
||||||
|
}
|
||||||
|
|
||||||
|
uidList = make([]string, 0)
|
||||||
|
unDefaultServiceNameList = make([]string, 0)
|
||||||
|
//检查套餐中是否有默认值
|
||||||
|
for _, uuid := range uuids {
|
||||||
|
hasDefault := false
|
||||||
|
service, exists := serviceMap[uuid]
|
||||||
|
if !exists {
|
||||||
|
return nil, nil, fmt.Errorf("查询增值服务存储失败: %w", err)
|
||||||
|
}
|
||||||
|
for _, option := range service.Options {
|
||||||
|
if option.IsDefault {
|
||||||
|
uidList = append(uidList, uuid)
|
||||||
|
hasDefault = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !hasDefault {
|
||||||
|
unDefaultServiceNameList = append(unDefaultServiceNameList, service.ServiceName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -123,7 +123,7 @@ func GetUsedRecord(req *bundle.GetUsedRecordListReq) (*bundle.GetUsedRecordListR
|
|||||||
}
|
}
|
||||||
resp := &bundle.GetUsedRecordListResp{}
|
resp := &bundle.GetUsedRecordListResp{}
|
||||||
resp.Total = total
|
resp.Total = total
|
||||||
resp.Data = lo.Map(data, func(m model.CostLogPo, _ int) *bundle.WorkCastItem {
|
resp.Data = lo.Map(data, func(m model.CostLog, _ int) *bundle.WorkCastItem {
|
||||||
result := &bundle.WorkCastItem{}
|
result := &bundle.WorkCastItem{}
|
||||||
copier.Copy(result, &m)
|
copier.Copy(result, &m)
|
||||||
return result
|
return result
|
||||||
|
@ -3,10 +3,12 @@ package logic
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"micro-bundle/internal/dao"
|
"micro-bundle/internal/dao"
|
||||||
"micro-bundle/pb/bundle"
|
"micro-bundle/pb/bundle"
|
||||||
"micro-bundle/pkg/app"
|
"micro-bundle/pkg/app"
|
||||||
"micro-bundle/pkg/msg"
|
"micro-bundle/pkg/msg"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"micro-bundle/internal/model"
|
"micro-bundle/internal/model"
|
||||||
@ -64,6 +66,7 @@ func SaveBundle(req *bundle.BundleProfile) (res *bundle.SaveResponse, err error)
|
|||||||
if req.Sort <= 0 {
|
if req.Sort <= 0 {
|
||||||
return res, errors.New("排序参数需为正整数")
|
return res, errors.New("排序参数需为正整数")
|
||||||
}
|
}
|
||||||
|
//套餐主表数据
|
||||||
bundleProfile := &model.BundleProfile{
|
bundleProfile := &model.BundleProfile{
|
||||||
Name: req.Name,
|
Name: req.Name,
|
||||||
Sort: req.Sort,
|
Sort: req.Sort,
|
||||||
@ -84,6 +87,7 @@ func SaveBundle(req *bundle.BundleProfile) (res *bundle.SaveResponse, err error)
|
|||||||
PriceType: req.PriceType,
|
PriceType: req.PriceType,
|
||||||
Language: req.Language,
|
Language: req.Language,
|
||||||
}
|
}
|
||||||
|
//必须先创建中文版本
|
||||||
if req.Uuid == "" && req.Language != msg.ZH_CN {
|
if req.Uuid == "" && req.Language != msg.ZH_CN {
|
||||||
return res, errors.New("请先创建中文版本套餐")
|
return res, errors.New("请先创建中文版本套餐")
|
||||||
}
|
}
|
||||||
@ -99,28 +103,122 @@ func SaveBundle(req *bundle.BundleProfile) (res *bundle.SaveResponse, err error)
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
//现需要区分类型 分为 1:套餐权益,该类型必须关联一个可用时长类型的权益 2:套餐可选附加权益,非必选可为空
|
||||||
selectService := make([]*model.BundleToValueAddService, 0)
|
selectService := make([]*model.BundleToValueAddService, 0)
|
||||||
var selectValueAddServiceCount = make(map[int]struct{}) //增值服务类型数量
|
//搜集所有增值服务的uuid
|
||||||
if req.Language == msg.ZH_CN && req.SelectValueAddService != nil && len(req.SelectValueAddService) > 0 {
|
if req.Language == msg.ZH_CN {
|
||||||
for _, v := range req.SelectValueAddService {
|
//符合条件的增值服务uuid
|
||||||
detail, checkErr := dao.ValueAddServiceDetailByUuidAndLanguage(v.ValueAddUuid, req.Language)
|
var allValueUuids []string
|
||||||
if checkErr != nil {
|
//批量查询得到的增值服务详情
|
||||||
if checkErr == gorm.ErrRecordNotFound {
|
serviceDetails := make(map[string]*model.ValueAddServiceLang)
|
||||||
|
//套餐权益增值服务类型数量
|
||||||
|
var pkgBenefitsValueAddServiceCount = make(map[int]struct{})
|
||||||
|
//套餐可选附加权益增值服务类型数量
|
||||||
|
var pkgOptionalValueAddServiceCount = make(map[int]struct{})
|
||||||
|
if req.SelectValueAddService != nil {
|
||||||
|
for _, v := range req.SelectValueAddService {
|
||||||
|
allValueUuids = append(allValueUuids, v.ValueAddUuid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if req.SelectValueAdditionalService != nil {
|
||||||
|
for _, v := range req.SelectValueAdditionalService {
|
||||||
|
allValueUuids = append(allValueUuids, v.ValueAddUuid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 批量查询增值服务详情
|
||||||
|
if len(allValueUuids) > 0 {
|
||||||
|
//筛选uid对应的增值服务是否有默认值
|
||||||
|
// _, unDefaultServiceNameList, err := dao.CheckDefaultServiceValueWithUid(allValueUuids, req.Language)
|
||||||
|
// if err != nil {
|
||||||
|
// return res, errors.New("筛选增值服务默认值失败")
|
||||||
|
// }
|
||||||
|
// if len(unDefaultServiceNameList) > 0 {
|
||||||
|
// warningMsg := "增值服务没有默认套餐数量: " + strings.Join(unDefaultServiceNameList, ",") + "请选择默认套餐数量后重新添加"
|
||||||
|
// res.Msg = warningMsg
|
||||||
|
// return res, errors.New(warningMsg)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
serviceDetails, err = dao.BatchGetValueAddServiceLang(allValueUuids, req.Language)
|
||||||
|
if err != nil {
|
||||||
|
return res, errors.New("批量查询增值服务失败")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.SelectValueAddService != nil && len(req.SelectValueAddService) > 0 {
|
||||||
|
// 获取套餐权益的额度映射
|
||||||
|
benefitsServices := make([]*model.BundleToValueAddService, 0)
|
||||||
|
|
||||||
|
for _, v := range req.SelectValueAddService {
|
||||||
|
detail, exists := serviceDetails[v.ValueAddUuid]
|
||||||
|
if !exists {
|
||||||
return res, errors.New("增值服务不存在")
|
return res, errors.New("增值服务不存在")
|
||||||
} else {
|
}
|
||||||
return res, errors.New("查询增值服务失败")
|
if _, exists := pkgBenefitsValueAddServiceCount[int(detail.ServiceType)]; exists {
|
||||||
|
return res, errors.New("每种增值服务类型只可选择一个")
|
||||||
|
}
|
||||||
|
|
||||||
|
benefitsServices = append(benefitsServices, &model.BundleToValueAddService{
|
||||||
|
ValueUid: v.ValueAddUuid,
|
||||||
|
})
|
||||||
|
|
||||||
|
pkgBenefitsValueAddServiceCount[int(detail.ServiceType)] = struct{}{}
|
||||||
|
selectService = append(selectService, &model.BundleToValueAddService{
|
||||||
|
ValueUid: v.ValueAddUuid,
|
||||||
|
IsDisplay: v.IsDisplay,
|
||||||
|
BenefitsType: msg.Benefits,
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
if req.SelectValueAdditionalService != nil && len(req.SelectValueAdditionalService) > 0 {
|
||||||
|
|
||||||
|
benefitsQuotaMap := dao.GetServiceQuotaMap(benefitsServices, serviceDetails)
|
||||||
|
|
||||||
|
for _, v := range req.SelectValueAdditionalService {
|
||||||
|
detail, exists := serviceDetails[v.ValueAddUuid]
|
||||||
|
if !exists {
|
||||||
|
return res, errors.New("增值服务不存在")
|
||||||
|
}
|
||||||
|
if _, exists := pkgOptionalValueAddServiceCount[int(detail.ServiceType)]; exists {
|
||||||
|
return res, errors.New("每种增值服务类型只可选择一个")
|
||||||
|
}
|
||||||
|
//额度兼容性验证
|
||||||
|
if benefitsQuota, exists := benefitsQuotaMap[detail.ServiceType]; exists {
|
||||||
|
optionalQuota := model.QuotaInfo{
|
||||||
|
QuotaType: detail.QuotaType,
|
||||||
|
QuotaValue: detail.QuotaValue,
|
||||||
|
}
|
||||||
|
|
||||||
|
if !dao.ValidateQuotaCompatibility(benefitsQuota, optionalQuota) {
|
||||||
|
var serviceName string
|
||||||
|
switch detail.ServiceType {
|
||||||
|
case msg.VideoService:
|
||||||
|
serviceName = "视频"
|
||||||
|
case msg.TextService:
|
||||||
|
serviceName = "图文"
|
||||||
|
case msg.DataReportService:
|
||||||
|
serviceName = "数据报表"
|
||||||
|
case msg.AccountService:
|
||||||
|
serviceName = "账号数"
|
||||||
|
case msg.AvailableTimeService:
|
||||||
|
serviceName = "可用时长"
|
||||||
|
}
|
||||||
|
return res, fmt.Errorf("服务类型%s的额度不兼容:套餐权益额度为%d,附加权益额度为%d",
|
||||||
|
serviceName, benefitsQuota.QuotaValue, optionalQuota.QuotaValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pkgOptionalValueAddServiceCount[int(detail.ServiceType)] = struct{}{}
|
||||||
|
selectService = append(selectService, &model.BundleToValueAddService{
|
||||||
|
ValueUid: v.ValueAddUuid,
|
||||||
|
IsDisplay: v.IsDisplay,
|
||||||
|
BenefitsType: msg.OptionalBenefits,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, exists := selectValueAddServiceCount[int(detail.ServiceType)]; exists {
|
|
||||||
return res, errors.New("每种增值服务类型只可选择一个")
|
|
||||||
}
|
|
||||||
selectValueAddServiceCount[int(detail.ServiceType)] = struct{}{}
|
|
||||||
selectService = append(selectService, &model.BundleToValueAddService{
|
|
||||||
ValueUid: v.ValueAddUuid,
|
|
||||||
IsDisplay: v.IsDisplay,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tx := app.ModuleClients.BundleDB.Begin()
|
tx := app.ModuleClients.BundleDB.Begin()
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -235,8 +333,7 @@ func BundleListV2(req *bundle.BundleListRequest) (res *bundle.BundleListResponse
|
|||||||
func BundleDetailV2(req *bundle.BundleDetailRequest) (res *bundle.BundleDetailResponseV2, err error) {
|
func BundleDetailV2(req *bundle.BundleDetailRequest) (res *bundle.BundleDetailResponseV2, err error) {
|
||||||
res = new(bundle.BundleDetailResponseV2)
|
res = new(bundle.BundleDetailResponseV2)
|
||||||
bundleProfile := &bundle.BundleProfile{}
|
bundleProfile := &bundle.BundleProfile{}
|
||||||
bundleProfileLangs := make([]*bundle.BundleProfileLang, 0)
|
|
||||||
selectValueAddServices := make([]*bundle.SelectValueAddService, 0) //已选增值服务
|
|
||||||
if req.Uuid == "" {
|
if req.Uuid == "" {
|
||||||
return res, errors.New("缺少套餐UUID")
|
return res, errors.New("缺少套餐UUID")
|
||||||
}
|
}
|
||||||
@ -245,38 +342,85 @@ func BundleDetailV2(req *bundle.BundleDetailRequest) (res *bundle.BundleDetailRe
|
|||||||
return res, errors.New("获取套餐信息失败")
|
return res, errors.New("获取套餐信息失败")
|
||||||
}
|
}
|
||||||
if detail != nil {
|
if detail != nil {
|
||||||
bundleProfile.Uuid = detail.UUID
|
bundleProfile = &bundle.BundleProfile{
|
||||||
bundleProfile.Name = detail.Name
|
Uuid: detail.UUID,
|
||||||
bundleProfile.Content = detail.Content
|
Name: detail.Name,
|
||||||
bundleProfile.Price = detail.Price
|
Content: detail.Content,
|
||||||
bundleProfile.PriceType = detail.PriceType
|
Price: detail.Price,
|
||||||
bundleProfile.ImgOption = int32(detail.ImgOption)
|
PriceType: detail.PriceType,
|
||||||
bundleProfile.BgImg1 = detail.BgImg1
|
ImgOption: int32(detail.ImgOption),
|
||||||
bundleProfile.BgImg2 = detail.BgImg2
|
BgImg1: detail.BgImg1,
|
||||||
bundleProfile.FontColor = detail.FontColor
|
BgImg2: detail.BgImg2,
|
||||||
bundleProfile.Sort = detail.Sort
|
FontColor: detail.FontColor,
|
||||||
bundleProfile.ShelfStatus = detail.ShelfStatus
|
Sort: detail.Sort,
|
||||||
bundleProfile.CreatedAt = detail.CreatedAt.Format("2006-01-02 15:04:05")
|
ShelfStatus: detail.ShelfStatus,
|
||||||
bundleProfile.UpdatedAt = detail.UpdatedAt.Format("2006-01-02 15:04:05")
|
CreatedAt: detail.CreatedAt.Format("2006-01-02 15:04:05"),
|
||||||
bundleProfile.Contract = detail.Contract
|
UpdatedAt: detail.UpdatedAt.Format("2006-01-02 15:04:05"),
|
||||||
|
Contract: detail.Contract,
|
||||||
|
}
|
||||||
if len(detail.BundleToValueAddService) > 0 {
|
if len(detail.BundleToValueAddService) > 0 {
|
||||||
|
var valueUuids []string
|
||||||
|
for _, service := range detail.BundleToValueAddService {
|
||||||
|
valueUuids = append(valueUuids, service.ValueUid)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量查询增值服务详情
|
||||||
|
valueAddServiceMap, err := dao.BatchGetValueAddServiceLang(valueUuids, req.Language)
|
||||||
|
if err != nil {
|
||||||
|
return res, errors.New("批量查询增值服务失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
selectValueAddServices := make([]*bundle.SelectValueAddService, 0) //已选套餐服务
|
||||||
|
selectValueAdditionalServices := make([]*bundle.SelectValueAdditionalService, 0) //已选套餐可选附加服务
|
||||||
|
|
||||||
for _, valueAddService := range detail.BundleToValueAddService {
|
for _, valueAddService := range detail.BundleToValueAddService {
|
||||||
valueAddDetail, err := dao.ValueAddServiceDetailByUuidAndLanguage(valueAddService.ValueUid, req.Language)
|
valueAddDetail, exists := valueAddServiceMap[valueAddService.ValueUid]
|
||||||
if err != nil {
|
if !exists {
|
||||||
return res, errors.New("查询增值服务失败")
|
return res, errors.New("查询增值服务失败")
|
||||||
}
|
}
|
||||||
selectValueAddService := &bundle.SelectValueAddService{
|
|
||||||
ValueAddUuid: valueAddService.ValueUid,
|
// 查找默认选项
|
||||||
IsDisplay: valueAddService.IsDisplay,
|
var defaultServiceValue int32
|
||||||
ServiceName: valueAddDetail.ServiceName,
|
for _, option := range valueAddDetail.Options {
|
||||||
ServiceType: valueAddDetail.ServiceType,
|
if option.IsDefault {
|
||||||
|
defaultServiceValue = option.Num
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//根据权益类型不同进行分类存放
|
||||||
|
switch valueAddService.BenefitsType {
|
||||||
|
case msg.Benefits:
|
||||||
|
selectValueAddServices = append(selectValueAddServices, &bundle.SelectValueAddService{
|
||||||
|
ValueAddUuid: valueAddService.ValueUid,
|
||||||
|
IsDisplay: valueAddService.IsDisplay,
|
||||||
|
ServiceName: valueAddDetail.ServiceName,
|
||||||
|
ServiceType: valueAddDetail.ServiceType,
|
||||||
|
QuotaType: valueAddDetail.QuotaType,
|
||||||
|
QuotaValue: valueAddDetail.QuotaValue,
|
||||||
|
IsExpired: valueAddDetail.IsExpired,
|
||||||
|
DefaultServiceValue: defaultServiceValue,
|
||||||
|
})
|
||||||
|
case msg.OptionalBenefits:
|
||||||
|
selectValueAdditionalServices = append(selectValueAdditionalServices, &bundle.SelectValueAdditionalService{
|
||||||
|
ValueAddUuid: valueAddService.ValueUid,
|
||||||
|
IsDisplay: valueAddService.IsDisplay,
|
||||||
|
ServiceName: valueAddDetail.ServiceName,
|
||||||
|
ServiceType: valueAddDetail.ServiceType,
|
||||||
|
QuotaType: valueAddDetail.QuotaType,
|
||||||
|
QuotaValue: valueAddDetail.QuotaValue,
|
||||||
|
IsExpired: valueAddDetail.IsExpired,
|
||||||
|
DefaultServiceValue: defaultServiceValue,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
selectValueAddServices = append(selectValueAddServices, selectValueAddService)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bundleProfile.SelectValueAddService = selectValueAddServices
|
||||||
|
bundleProfile.SelectValueAdditionalService = selectValueAdditionalServices
|
||||||
}
|
}
|
||||||
if len(detail.BundleProfileLang) > 0 {
|
if len(detail.BundleProfileLang) > 0 {
|
||||||
|
bundleProfileLangs := make([]*bundle.BundleProfileLang, 0, len(detail.BundleProfileLang))
|
||||||
for _, lang := range detail.BundleProfileLang {
|
for _, lang := range detail.BundleProfileLang {
|
||||||
bundleProfileLang := &bundle.BundleProfileLang{
|
bundleProfileLangs = append(bundleProfileLangs, &bundle.BundleProfileLang{
|
||||||
Uuid: lang.UUID,
|
Uuid: lang.UUID,
|
||||||
Name: lang.Name,
|
Name: lang.Name,
|
||||||
Price: lang.Price,
|
Price: lang.Price,
|
||||||
@ -291,16 +435,11 @@ func BundleDetailV2(req *bundle.BundleDetailRequest) (res *bundle.BundleDetailRe
|
|||||||
ShelfStatus: detail.ShelfStatus,
|
ShelfStatus: detail.ShelfStatus,
|
||||||
CreatedAt: time.Unix(lang.CreatedAt, 0).Format("2006-01-02 15:04:05"),
|
CreatedAt: time.Unix(lang.CreatedAt, 0).Format("2006-01-02 15:04:05"),
|
||||||
UpdatedAt: time.Unix(int64(lang.UpdatedAt), 0).Format("2006-01-02 15:04:05"),
|
UpdatedAt: time.Unix(int64(lang.UpdatedAt), 0).Format("2006-01-02 15:04:05"),
|
||||||
}
|
})
|
||||||
bundleProfileLangs = append(bundleProfileLangs, bundleProfileLang)
|
|
||||||
}
|
}
|
||||||
|
bundleProfile.BundleProfileLang = bundleProfileLangs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(selectValueAddServices) > 0 {
|
|
||||||
bundleProfile.SelectValueAddService = selectValueAddServices
|
|
||||||
}
|
|
||||||
bundleProfile.BundleProfileLang = bundleProfileLangs
|
|
||||||
res.Bundle = bundleProfile
|
res.Bundle = bundleProfile
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -316,6 +455,7 @@ func BundleLangDetailV2(req *bundle.BundleDetailRequest) (res *bundle.BundleProf
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return res, errors.New("获取套餐信息失败")
|
return res, errors.New("获取套餐信息失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
lang, err := dao.BundleDetailByUuidAndLanguage(req.Uuid, req.Language)
|
lang, err := dao.BundleDetailByUuidAndLanguage(req.Uuid, req.Language)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, errors.New("获取套餐信息失败")
|
return res, errors.New("获取套餐信息失败")
|
||||||
@ -329,6 +469,16 @@ func BundleLangDetailV2(req *bundle.BundleDetailRequest) (res *bundle.BundleProf
|
|||||||
res.Sort = detail.Sort
|
res.Sort = detail.Sort
|
||||||
res.ShelfStatus = detail.ShelfStatus
|
res.ShelfStatus = detail.ShelfStatus
|
||||||
res.Contract = detail.Contract
|
res.Contract = detail.Contract
|
||||||
|
if len(detail.BundleToValueAddService) > 0 {
|
||||||
|
var serviceLangInfos []*bundle.ServiceLangInfo
|
||||||
|
for _, service := range detail.BundleToValueAddService {
|
||||||
|
serviceLangInfos = append(serviceLangInfos, &bundle.ServiceLangInfo{
|
||||||
|
ValueAddUuid: service.ValueUid,
|
||||||
|
BenefitsType: service.BenefitsType,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
res.ServiceLangInfo = serviceLangInfos
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if lang != nil {
|
if lang != nil {
|
||||||
res.Name = lang.Name
|
res.Name = lang.Name
|
||||||
@ -423,42 +573,64 @@ func HandleShelf(req *bundle.HandShelfRequest) (*bundle.CommonResponse, error) {
|
|||||||
|
|
||||||
// 差异更新套餐与增值服务中间表
|
// 差异更新套餐与增值服务中间表
|
||||||
func diffUpdateBundleToValueAddService(tx *gorm.DB, bundleUuid string, selectService []*model.BundleToValueAddService) error {
|
func diffUpdateBundleToValueAddService(tx *gorm.DB, bundleUuid string, selectService []*model.BundleToValueAddService) error {
|
||||||
oldUuids, err := dao.GetValueAddServiceUuidsByBundleUuid(bundleUuid)
|
// 获取现有的关联记录(包含value_uid和benefits_type)
|
||||||
|
oldRecords, err := dao.GetValueAddServiceUuidsByAndBenefitsBundleUuid(bundleUuid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("查询套餐与增值服务关联失败")
|
return errors.New("查询套餐与增值服务关联失败")
|
||||||
}
|
}
|
||||||
newUuids := make(map[string]*model.BundleToValueAddService)
|
|
||||||
|
// 构建现有记录的复合键映射 (value_uid + benefits_type)
|
||||||
|
oldMap := make(map[string]struct{})
|
||||||
|
for _, record := range oldRecords {
|
||||||
|
key := fmt.Sprintf("%s_%d", record.ValueUid, record.BenefitsType)
|
||||||
|
oldMap[key] = struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建新记录的复合键映射
|
||||||
|
newMap := make(map[string]*model.BundleToValueAddService)
|
||||||
for _, s := range selectService {
|
for _, s := range selectService {
|
||||||
newUuids[s.ValueUid] = s
|
key := fmt.Sprintf("%s_%d", s.ValueUid, s.BenefitsType)
|
||||||
}
|
s.BundleUuid = bundleUuid
|
||||||
oldSet := make(map[string]struct{})
|
newMap[key] = s
|
||||||
for _, uid := range oldUuids {
|
|
||||||
oldSet[uid] = struct{}{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 需要新增的
|
// 需要新增的
|
||||||
toAdd := make([]*model.BundleToValueAddService, 0)
|
toAdd := make([]*model.BundleToValueAddService, 0)
|
||||||
toDel := make([]string, 0)
|
toDel := make([]string, 0)
|
||||||
toUpdate := make([]*model.BundleToValueAddService, 0)
|
toUpdate := make([]*model.BundleToValueAddService, 0)
|
||||||
for uid, s := range newUuids {
|
|
||||||
if _, exist := oldSet[uid]; !exist {
|
for key, newRecord := range newMap {
|
||||||
s.BundleUuid = bundleUuid
|
if _, exists := oldMap[key]; exists {
|
||||||
toAdd = append(toAdd, s)
|
// 记录存在,需要更新
|
||||||
|
toUpdate = append(toUpdate, newRecord)
|
||||||
} else {
|
} else {
|
||||||
s.BundleUuid = bundleUuid
|
// 记录不存在,需要新增
|
||||||
toUpdate = append(toUpdate, s)
|
toAdd = append(toAdd, newRecord)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 需要删除的
|
// 需要删除的
|
||||||
for _, uid := range oldUuids {
|
for key := range oldMap {
|
||||||
if _, exist := newUuids[uid]; !exist {
|
if _, exists := newMap[key]; !exists {
|
||||||
toDel = append(toDel, uid)
|
// 旧记录在新数据中不存在,需要删除
|
||||||
|
toDel = append(toDel, key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(toDel) > 0 {
|
if len(toDel) > 0 {
|
||||||
if err = tx.Where("bundle_uuid = ? AND value_uid IN ?", bundleUuid, toDel).Delete(&model.BundleToValueAddService{}).Error; err != nil {
|
for _, key := range toDel {
|
||||||
return errors.New("删除套餐与增值服务关联失败")
|
parts := strings.Split(key, "_")
|
||||||
|
if len(parts) == 2 {
|
||||||
|
valueUid := parts[0]
|
||||||
|
benefitsType := parts[1]
|
||||||
|
if err = tx.Where("bundle_uuid = ? AND value_uid = ? AND benefits_type = ? AND deleted_at = 0",
|
||||||
|
bundleUuid, valueUid, benefitsType).Delete(&model.BundleToValueAddService{}).Error; err != nil {
|
||||||
|
return errors.New("删除套餐与增值服务关联失败")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(toAdd) > 0 {
|
if len(toAdd) > 0 {
|
||||||
if err = dao.CreateBundleToValueAddService(tx, toAdd); err != nil {
|
if err = dao.CreateBundleToValueAddService(tx, toAdd); err != nil {
|
||||||
return errors.New("保存套餐与增值服务关联失败")
|
return errors.New("保存套餐与增值服务关联失败")
|
||||||
|
@ -165,18 +165,7 @@ func SaveValueAddService(in *bundle.ValueAddServiceLang) (res *bundle.SaveRespon
|
|||||||
price, parseErr1 := strconv.ParseFloat(option.Price, 32)
|
price, parseErr1 := strconv.ParseFloat(option.Price, 32)
|
||||||
if parseErr1 != nil {
|
if parseErr1 != nil {
|
||||||
fmt.Println("优惠单价转换失败: ", parseErr1)
|
fmt.Println("优惠单价转换失败: ", parseErr1)
|
||||||
return res, errors.New("单价不能为空: " + parseErr1.Error())
|
return res, errors.New("优惠单价转换失败")
|
||||||
}
|
|
||||||
if option.TotalPrice == "" {
|
|
||||||
if option.Symbol == "=" {
|
|
||||||
return res, errors.New("总价不能为空")
|
|
||||||
}
|
|
||||||
option.TotalPrice = "0"
|
|
||||||
}
|
|
||||||
totalPrice, parseErr2 := strconv.ParseFloat(option.TotalPrice, 32)
|
|
||||||
if parseErr2 != nil {
|
|
||||||
fmt.Println("总价转换失败: ", parseErr2)
|
|
||||||
return res, errors.New("总价转换失败: " + parseErr2.Error())
|
|
||||||
}
|
}
|
||||||
if option.Num < 0 || option.Num > 99 {
|
if option.Num < 0 || option.Num > 99 {
|
||||||
return res, errors.New("数量参数需为0-99")
|
return res, errors.New("数量参数需为0-99")
|
||||||
@ -185,14 +174,27 @@ func SaveValueAddService(in *bundle.ValueAddServiceLang) (res *bundle.SaveRespon
|
|||||||
return res, errors.New("优惠单价需小于等于原价")
|
return res, errors.New("优惠单价需小于等于原价")
|
||||||
}
|
}
|
||||||
options = append(options, &model.PriceOption{
|
options = append(options, &model.PriceOption{
|
||||||
Id: int32(index),
|
Id: int32(index),
|
||||||
Num: option.Num,
|
Num: option.Num,
|
||||||
Symbol: option.Symbol,
|
Symbol: option.Symbol,
|
||||||
Price: float32(price),
|
Price: float32(price),
|
||||||
TotalPrice: float32(totalPrice),
|
IsDefault: option.IsDefault,
|
||||||
})
|
})
|
||||||
index++
|
index++
|
||||||
}
|
}
|
||||||
|
hasDefault := false
|
||||||
|
for _, option := range options {
|
||||||
|
if option.IsDefault {
|
||||||
|
if option.Symbol != "=" {
|
||||||
|
return res, errors.New("默认套餐数量只能选择数量符合为等于的选项")
|
||||||
|
}
|
||||||
|
hasDefault = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !hasDefault {
|
||||||
|
return res, errors.New("请选择默认套餐数量")
|
||||||
|
}
|
||||||
ok, err := model.ValidateOptions(options)
|
ok, err := model.ValidateOptions(options)
|
||||||
if !ok {
|
if !ok {
|
||||||
return res, err
|
return res, err
|
||||||
@ -210,6 +212,9 @@ func SaveValueAddService(in *bundle.ValueAddServiceLang) (res *bundle.SaveRespon
|
|||||||
Language: in.Language,
|
Language: in.Language,
|
||||||
PriceType: in.PriceType,
|
PriceType: in.PriceType,
|
||||||
Options: options,
|
Options: options,
|
||||||
|
QuotaType: in.QuotaType,
|
||||||
|
QuotaValue: in.QuotaValue,
|
||||||
|
IsExpired: in.IsExpired,
|
||||||
}
|
}
|
||||||
if in.Uuid == "" && in.Language != msg.ZH_CN {
|
if in.Uuid == "" && in.Language != msg.ZH_CN {
|
||||||
return res, errors.New("请先创建中文版本增值服务")
|
return res, errors.New("请先创建中文版本增值服务")
|
||||||
@ -271,6 +276,9 @@ func SaveValueAddService(in *bundle.ValueAddServiceLang) (res *bundle.SaveRespon
|
|||||||
Language: lang,
|
Language: lang,
|
||||||
PriceType: valueAddServiceLang.PriceType,
|
PriceType: valueAddServiceLang.PriceType,
|
||||||
Options: valueAddServiceLang.Options,
|
Options: valueAddServiceLang.Options,
|
||||||
|
QuotaType: valueAddServiceLang.QuotaType,
|
||||||
|
QuotaValue: valueAddServiceLang.QuotaValue,
|
||||||
|
IsExpired: valueAddServiceLang.IsExpired,
|
||||||
}
|
}
|
||||||
otherLang.Language = lang
|
otherLang.Language = lang
|
||||||
if err = dao.CreateValueAddServiceLang(tx, &otherLang); err != nil {
|
if err = dao.CreateValueAddServiceLang(tx, &otherLang); err != nil {
|
||||||
@ -297,6 +305,14 @@ func SaveValueAddService(in *bundle.ValueAddServiceLang) (res *bundle.SaveRespon
|
|||||||
if err = dao.UpdateValueAddService(tx, updateService); err != nil {
|
if err = dao.UpdateValueAddService(tx, updateService); err != nil {
|
||||||
return res, errors.New("更新增值服务失败")
|
return res, errors.New("更新增值服务失败")
|
||||||
}
|
}
|
||||||
|
updataAllLangServiceType := map[string]interface{}{
|
||||||
|
"uuid": in.Uuid,
|
||||||
|
"service_type": in.ServiceType,
|
||||||
|
"unit": in.Unit,
|
||||||
|
}
|
||||||
|
if err = dao.UpdateAllValueAddServiceLangServiceType(tx, updataAllLangServiceType); err != nil {
|
||||||
|
return res, errors.New("更新增值服务失败")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//更新语言表
|
//更新语言表
|
||||||
updateLangService := map[string]interface{}{
|
updateLangService := map[string]interface{}{
|
||||||
@ -309,6 +325,9 @@ func SaveValueAddService(in *bundle.ValueAddServiceLang) (res *bundle.SaveRespon
|
|||||||
"price_type": in.PriceType,
|
"price_type": in.PriceType,
|
||||||
"options": options,
|
"options": options,
|
||||||
"language": in.Language,
|
"language": in.Language,
|
||||||
|
"quota_type": in.QuotaType,
|
||||||
|
"quota_value": in.QuotaValue,
|
||||||
|
"is_expired": in.IsExpired,
|
||||||
}
|
}
|
||||||
if err := dao.UpdateValueAddServiceLang(tx, updateLangService); err != nil {
|
if err := dao.UpdateValueAddServiceLang(tx, updateLangService); err != nil {
|
||||||
return res, errors.New("更新增值服务失败")
|
return res, errors.New("更新增值服务失败")
|
||||||
@ -349,6 +368,9 @@ func ValueAddServiceList(req *bundle.ValueAddServiceListRequest) (res *bundle.Va
|
|||||||
ServiceType: valueAddService.ServiceType,
|
ServiceType: valueAddService.ServiceType,
|
||||||
}
|
}
|
||||||
for _, serviceLang := range valueAddService.ValueAddServiceLang {
|
for _, serviceLang := range valueAddService.ValueAddServiceLang {
|
||||||
|
if serviceLang.QuotaType == 0 && serviceInfo.ServiceType != msg.AccountService && serviceInfo.ServiceType != msg.AvailableTimeService {
|
||||||
|
serviceLang.QuotaType = msg.UnlimitedQuota
|
||||||
|
}
|
||||||
serviceLangInfo := &bundle.ValueAddServiceLang{
|
serviceLangInfo := &bundle.ValueAddServiceLang{
|
||||||
Uuid: valueAddService.UUID,
|
Uuid: valueAddService.UUID,
|
||||||
ServiceName: serviceLang.ServiceName,
|
ServiceName: serviceLang.ServiceName,
|
||||||
@ -360,6 +382,14 @@ func ValueAddServiceList(req *bundle.ValueAddServiceListRequest) (res *bundle.Va
|
|||||||
Language: serviceLang.Language,
|
Language: serviceLang.Language,
|
||||||
CreatedAt: time.Unix(serviceLang.CreatedAt, 0).Format("2006-01-02 15:04:05"),
|
CreatedAt: time.Unix(serviceLang.CreatedAt, 0).Format("2006-01-02 15:04:05"),
|
||||||
UpdatedAt: time.Unix(serviceLang.UpdatedAt, 0).Format("2006-01-02 15:04:05"),
|
UpdatedAt: time.Unix(serviceLang.UpdatedAt, 0).Format("2006-01-02 15:04:05"),
|
||||||
|
QuotaType: serviceLang.QuotaType,
|
||||||
|
QuotaValue: serviceLang.QuotaValue,
|
||||||
|
IsExpired: serviceLang.IsExpired,
|
||||||
|
}
|
||||||
|
if serviceLangInfo.Language == msg.ZH_CN && serviceInfo.ServiceType != 5 && serviceInfo.ServiceType != 4 {
|
||||||
|
serviceInfo.QuotaType = serviceLangInfo.QuotaType
|
||||||
|
serviceInfo.QuotaValue = serviceLangInfo.QuotaValue
|
||||||
|
serviceInfo.IsExpired = serviceLangInfo.IsExpired
|
||||||
}
|
}
|
||||||
if len(serviceLang.Options) > 0 {
|
if len(serviceLang.Options) > 0 {
|
||||||
var options []*bundle.ValueAddPriceOptions
|
var options []*bundle.ValueAddPriceOptions
|
||||||
@ -370,12 +400,7 @@ func ValueAddServiceList(req *bundle.ValueAddServiceListRequest) (res *bundle.Va
|
|||||||
original := decimal.NewFromFloat(float64(serviceLang.OriginalPrice))
|
original := decimal.NewFromFloat(float64(serviceLang.OriginalPrice))
|
||||||
price := decimal.NewFromFloat(float64(option.Price))
|
price := decimal.NewFromFloat(float64(option.Price))
|
||||||
num := decimal.NewFromInt(int64(option.Num))
|
num := decimal.NewFromInt(int64(option.Num))
|
||||||
totalPrice := decimal.NewFromFloat(float64(option.TotalPrice))
|
saveAmount = original.Sub(price).Mul(num)
|
||||||
if !totalPrice.IsZero() {
|
|
||||||
saveAmount = (original.Mul(num)).Sub(totalPrice)
|
|
||||||
} else {
|
|
||||||
saveAmount = original.Sub(price).Mul(num)
|
|
||||||
}
|
|
||||||
case 2:
|
case 2:
|
||||||
//original := decimal.NewFromFloat(float64(serviceLang.OriginalPrice))
|
//original := decimal.NewFromFloat(float64(serviceLang.OriginalPrice))
|
||||||
//price := decimal.NewFromFloat(float64(option.Price))
|
//price := decimal.NewFromFloat(float64(option.Price))
|
||||||
@ -383,13 +408,17 @@ func ValueAddServiceList(req *bundle.ValueAddServiceListRequest) (res *bundle.Va
|
|||||||
default:
|
default:
|
||||||
return nil, errors.New("无效的价格模式")
|
return nil, errors.New("无效的价格模式")
|
||||||
}
|
}
|
||||||
|
//添加服务默认数量
|
||||||
|
if option.IsDefault && serviceLangInfo.Language == msg.ZH_CN {
|
||||||
|
serviceInfo.DefaultServiceValue = option.Num
|
||||||
|
}
|
||||||
options = append(options, &bundle.ValueAddPriceOptions{
|
options = append(options, &bundle.ValueAddPriceOptions{
|
||||||
Id: int64(option.Id),
|
Id: int64(option.Id),
|
||||||
Num: option.Num,
|
Num: option.Num,
|
||||||
Symbol: option.Symbol,
|
Symbol: option.Symbol,
|
||||||
Price: fmt.Sprintf("%.2f", option.Price),
|
Price: fmt.Sprintf("%.2f", option.Price),
|
||||||
TotalPrice: fmt.Sprintf("%.2f", option.TotalPrice),
|
|
||||||
SaveAmount: saveAmount.StringFixed(2),
|
SaveAmount: saveAmount.StringFixed(2),
|
||||||
|
IsDefault: option.IsDefault,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
serviceLangInfo.Options = options
|
serviceLangInfo.Options = options
|
||||||
@ -425,6 +454,9 @@ func ValueAddServiceDetail(req *bundle.ValueAddServiceDetailRequest) (res *bundl
|
|||||||
valueAddService.ServiceName = detail.ServiceName
|
valueAddService.ServiceName = detail.ServiceName
|
||||||
valueAddService.ServiceType = detail.ServiceType
|
valueAddService.ServiceType = detail.ServiceType
|
||||||
for _, serviceLang := range detail.ValueAddServiceLang {
|
for _, serviceLang := range detail.ValueAddServiceLang {
|
||||||
|
if serviceLang.QuotaType == 0 && valueAddService.ServiceType != msg.AccountService && valueAddService.ServiceType != msg.AvailableTimeService {
|
||||||
|
serviceLang.QuotaType = msg.UnlimitedQuota
|
||||||
|
}
|
||||||
langOptions := []*bundle.ValueAddPriceOptions{}
|
langOptions := []*bundle.ValueAddPriceOptions{}
|
||||||
if len(serviceLang.Options) > 0 {
|
if len(serviceLang.Options) > 0 {
|
||||||
for _, opt := range serviceLang.Options {
|
for _, opt := range serviceLang.Options {
|
||||||
@ -434,12 +466,7 @@ func ValueAddServiceDetail(req *bundle.ValueAddServiceDetailRequest) (res *bundl
|
|||||||
original := decimal.NewFromFloat(float64(serviceLang.OriginalPrice))
|
original := decimal.NewFromFloat(float64(serviceLang.OriginalPrice))
|
||||||
price := decimal.NewFromFloat(float64(opt.Price))
|
price := decimal.NewFromFloat(float64(opt.Price))
|
||||||
num := decimal.NewFromInt(int64(opt.Num))
|
num := decimal.NewFromInt(int64(opt.Num))
|
||||||
totalPrice := decimal.NewFromFloat(float64(opt.TotalPrice))
|
saveAmount = original.Sub(price).Mul(num)
|
||||||
if !totalPrice.IsZero() {
|
|
||||||
saveAmount = (original.Mul(num)).Sub(totalPrice)
|
|
||||||
} else {
|
|
||||||
saveAmount = original.Sub(price).Mul(num)
|
|
||||||
}
|
|
||||||
case 2:
|
case 2:
|
||||||
//original := decimal.NewFromFloat(float64(serviceLang.OriginalPrice))
|
//original := decimal.NewFromFloat(float64(serviceLang.OriginalPrice))
|
||||||
//price := decimal.NewFromFloat(float64(opt.Price))
|
//price := decimal.NewFromFloat(float64(opt.Price))
|
||||||
@ -452,8 +479,8 @@ func ValueAddServiceDetail(req *bundle.ValueAddServiceDetailRequest) (res *bundl
|
|||||||
Num: opt.Num,
|
Num: opt.Num,
|
||||||
Symbol: opt.Symbol,
|
Symbol: opt.Symbol,
|
||||||
Price: fmt.Sprintf("%.2f", opt.Price),
|
Price: fmt.Sprintf("%.2f", opt.Price),
|
||||||
TotalPrice: fmt.Sprintf("%.2f", opt.TotalPrice),
|
|
||||||
SaveAmount: saveAmount.StringFixed(2),
|
SaveAmount: saveAmount.StringFixed(2),
|
||||||
|
IsDefault: opt.IsDefault,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -469,6 +496,9 @@ func ValueAddServiceDetail(req *bundle.ValueAddServiceDetailRequest) (res *bundl
|
|||||||
Options: langOptions,
|
Options: langOptions,
|
||||||
CreatedAt: time.Unix(serviceLang.CreatedAt, 0).Format("2006-01-02 15:04:05"),
|
CreatedAt: time.Unix(serviceLang.CreatedAt, 0).Format("2006-01-02 15:04:05"),
|
||||||
UpdatedAt: time.Unix(serviceLang.UpdatedAt, 0).Format("2006-01-02 15:04:05"),
|
UpdatedAt: time.Unix(serviceLang.UpdatedAt, 0).Format("2006-01-02 15:04:05"),
|
||||||
|
QuotaType: serviceLang.QuotaType,
|
||||||
|
QuotaValue: serviceLang.QuotaValue,
|
||||||
|
IsExpired: serviceLang.IsExpired,
|
||||||
}
|
}
|
||||||
serviceLangs = append(serviceLangs, serviceLangInfo)
|
serviceLangs = append(serviceLangs, serviceLangInfo)
|
||||||
}
|
}
|
||||||
@ -523,12 +553,7 @@ func ValueAddServiceDetailByUuidAndLanguage(req *bundle.ValueAddServiceDetailReq
|
|||||||
original := decimal.NewFromFloat(float64(detail.OriginalPrice))
|
original := decimal.NewFromFloat(float64(detail.OriginalPrice))
|
||||||
price := decimal.NewFromFloat(float64(opt.Price))
|
price := decimal.NewFromFloat(float64(opt.Price))
|
||||||
num := decimal.NewFromInt(int64(opt.Num))
|
num := decimal.NewFromInt(int64(opt.Num))
|
||||||
totalPrice := decimal.NewFromFloat(float64(opt.TotalPrice))
|
saveAmount = original.Sub(price).Mul(num)
|
||||||
if !totalPrice.IsZero() {
|
|
||||||
saveAmount = (original.Mul(num)).Sub(totalPrice)
|
|
||||||
} else {
|
|
||||||
saveAmount = original.Sub(price).Mul(num)
|
|
||||||
}
|
|
||||||
case 2:
|
case 2:
|
||||||
//original := decimal.NewFromFloat(float64(detail.OriginalPrice))
|
//original := decimal.NewFromFloat(float64(detail.OriginalPrice))
|
||||||
//price := decimal.NewFromFloat(float64(opt.Price))
|
//price := decimal.NewFromFloat(float64(opt.Price))
|
||||||
@ -541,8 +566,8 @@ func ValueAddServiceDetailByUuidAndLanguage(req *bundle.ValueAddServiceDetailReq
|
|||||||
Num: opt.Num,
|
Num: opt.Num,
|
||||||
Symbol: opt.Symbol,
|
Symbol: opt.Symbol,
|
||||||
Price: fmt.Sprintf("%.2f", opt.Price),
|
Price: fmt.Sprintf("%.2f", opt.Price),
|
||||||
TotalPrice: fmt.Sprintf("%.2f", opt.TotalPrice),
|
|
||||||
SaveAmount: saveAmount.StringFixed(2),
|
SaveAmount: saveAmount.StringFixed(2),
|
||||||
|
IsDefault: opt.IsDefault,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -558,6 +583,9 @@ func ValueAddServiceDetailByUuidAndLanguage(req *bundle.ValueAddServiceDetailReq
|
|||||||
Options: langOptions,
|
Options: langOptions,
|
||||||
CreatedAt: time.Unix(detail.CreatedAt, 0).Format("2006-01-02 15:04:05"),
|
CreatedAt: time.Unix(detail.CreatedAt, 0).Format("2006-01-02 15:04:05"),
|
||||||
UpdatedAt: time.Unix(detail.UpdatedAt, 0).Format("2006-01-02 15:04:05"),
|
UpdatedAt: time.Unix(detail.UpdatedAt, 0).Format("2006-01-02 15:04:05"),
|
||||||
|
QuotaType: detail.QuotaType,
|
||||||
|
QuotaValue: detail.QuotaValue,
|
||||||
|
IsExpired: detail.IsExpired,
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -616,12 +644,7 @@ func BatchGetValueAddServiceLang(req *bundle.BatchGetValueAddServiceLangRequest)
|
|||||||
original := decimal.NewFromFloat(float64(v.OriginalPrice))
|
original := decimal.NewFromFloat(float64(v.OriginalPrice))
|
||||||
price := decimal.NewFromFloat(float64(opt.Price))
|
price := decimal.NewFromFloat(float64(opt.Price))
|
||||||
num := decimal.NewFromInt(int64(opt.Num))
|
num := decimal.NewFromInt(int64(opt.Num))
|
||||||
totalPrice := decimal.NewFromFloat(float64(opt.TotalPrice))
|
saveAmount = original.Sub(price).Mul(num)
|
||||||
if !totalPrice.IsZero() {
|
|
||||||
saveAmount = (original.Mul(num)).Sub(totalPrice)
|
|
||||||
} else {
|
|
||||||
saveAmount = original.Sub(price).Mul(num)
|
|
||||||
}
|
|
||||||
case 2:
|
case 2:
|
||||||
//original := decimal.NewFromFloat(float64(v.OriginalPrice))
|
//original := decimal.NewFromFloat(float64(v.OriginalPrice))
|
||||||
//price := decimal.NewFromFloat(float64(opt.Price))
|
//price := decimal.NewFromFloat(float64(opt.Price))
|
||||||
@ -634,8 +657,8 @@ func BatchGetValueAddServiceLang(req *bundle.BatchGetValueAddServiceLangRequest)
|
|||||||
Num: opt.Num,
|
Num: opt.Num,
|
||||||
Symbol: opt.Symbol,
|
Symbol: opt.Symbol,
|
||||||
Price: fmt.Sprintf("%.2f", opt.Price),
|
Price: fmt.Sprintf("%.2f", opt.Price),
|
||||||
TotalPrice: fmt.Sprintf("%.2f", opt.TotalPrice),
|
|
||||||
SaveAmount: saveAmount.StringFixed(2),
|
SaveAmount: saveAmount.StringFixed(2),
|
||||||
|
IsDefault: opt.IsDefault,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ type BundleToValueAddService struct {
|
|||||||
ValueUid string `json:"valueUid" gorm:"column:value_uid;type:varchar(1024);comment:增值服务UUID"`
|
ValueUid string `json:"valueUid" gorm:"column:value_uid;type:varchar(1024);comment:增值服务UUID"`
|
||||||
ValueAddService ValueAddService `gorm:"foreignKey:ValueUid;references:UUID" json:"valueAddService"`
|
ValueAddService ValueAddService `gorm:"foreignKey:ValueUid;references:UUID" json:"valueAddService"`
|
||||||
IsDisplay bool `json:"isDisplay" gorm:"column:is_display;type:tinyint(1);comment:是否显示"`
|
IsDisplay bool `json:"isDisplay" gorm:"column:is_display;type:tinyint(1);comment:是否显示"`
|
||||||
|
BenefitsType int32 `json:"benefitsType" gorm:"column:benefits_type;type:int;comment:套餐权益类型 1:套餐权益 2:套餐可选附加权益"`
|
||||||
CreatedAt int64 `gorm:"column:created_at;autoCreateTime"`
|
CreatedAt int64 `gorm:"column:created_at;autoCreateTime"`
|
||||||
UpdatedAt int64 `gorm:"column:updated_at;autoCreateTime"`
|
UpdatedAt int64 `gorm:"column:updated_at;autoCreateTime"`
|
||||||
DeletedAt soft_delete.DeletedAt
|
DeletedAt soft_delete.DeletedAt
|
||||||
|
@ -101,7 +101,6 @@ type CastWorkLog struct {
|
|||||||
ArtistUuid string `gorm:"column:artist_uuid;type:varchar(50);comment:艺人ID;NOT NULL" json:"artist_uuid"`
|
ArtistUuid string `gorm:"column:artist_uuid;type:varchar(50);comment:艺人ID;NOT NULL" json:"artist_uuid"`
|
||||||
MediaAccUserIds string `gorm:"column:media_acc_user_ids;type:json;comment:自媒体账号user_ids集合;NOT NULL" json:"media_acc_user_ids"`
|
MediaAccUserIds string `gorm:"column:media_acc_user_ids;type:json;comment:自媒体账号user_ids集合;NOT NULL" json:"media_acc_user_ids"`
|
||||||
MediaNames string `gorm:"column:media_names;type:varchar(600);comment:自媒体账号名称集合;NOT NULL" json:"media_names"`
|
MediaNames string `gorm:"column:media_names;type:varchar(600);comment:自媒体账号名称集合;NOT NULL" json:"media_names"`
|
||||||
CostType int `gorm:"column:cost_type;type:int(11)" json:"costType"`
|
|
||||||
ConfirmedAt int64 `gorm:"column:confirmed_at;type:int(11)" json:"confirmedAt"`
|
ConfirmedAt int64 `gorm:"column:confirmed_at;type:int(11)" json:"confirmedAt"`
|
||||||
CreatedAt int `gorm:"column:created_at;type:int(11)" json:"created_at"`
|
CreatedAt int `gorm:"column:created_at;type:int(11)" json:"created_at"`
|
||||||
UpdatedAt int `gorm:"column:updated_at;type:int(11)" json:"updated_at"`
|
UpdatedAt int `gorm:"column:updated_at;type:int(11)" json:"updated_at"`
|
||||||
@ -111,8 +110,3 @@ type CastWorkLog struct {
|
|||||||
func (m *CastWorkLog) TableName() string {
|
func (m *CastWorkLog) TableName() string {
|
||||||
return "cast_work_log"
|
return "cast_work_log"
|
||||||
}
|
}
|
||||||
|
|
||||||
type CostLogPo struct {
|
|
||||||
CostLog
|
|
||||||
CostType int `gorm:"column:cost_type;type:int(11)" json:"costType"`
|
|
||||||
}
|
|
||||||
|
@ -51,14 +51,17 @@ type ValueAddServiceLang struct {
|
|||||||
ServiceType int32 `json:"serviceType" gorm:"column:service_type;type:int;comment:服务类型 1:视频 2:图文 3:数据报表 4:账号数 5:可用时长"`
|
ServiceType int32 `json:"serviceType" gorm:"column:service_type;type:int;comment:服务类型 1:视频 2:图文 3:数据报表 4:账号数 5:可用时长"`
|
||||||
PriceMode int32 `json:"priceMode" gorm:"column:price_mode;type:int;comment:套餐价格类型 1:单价 2:总价"`
|
PriceMode int32 `json:"priceMode" gorm:"column:price_mode;type:int;comment:套餐价格类型 1:单价 2:总价"`
|
||||||
OriginalPrice float32 `json:"originalPrice" gorm:"column:original_price;type:decimal(12,2);comment:原单价"`
|
OriginalPrice float32 `json:"originalPrice" gorm:"column:original_price;type:decimal(12,2);comment:原单价"`
|
||||||
TotalPrice float32 `json:"totalPrice" gorm:"column:total_price;type:decimal(12,2);comment:增值服务总价"` //总价模式不合理,该字段暂时无用
|
TotalPrice float32 `json:"totalPrice" gorm:"column:total_price;type:decimal(12,2);comment:增值服务总价"`
|
||||||
Unit string `json:"unit" gorm:"column:unit;type:varchar(50);comment:单位 1:个 2:条 3:天 4:月 5:年"`
|
Unit string `json:"unit" gorm:"column:unit;type:varchar(50);comment:单位 1:个 2:条 3:天 4:月 5:年 6:自然月 7:自然季度 8:半年 9:自然年"`
|
||||||
Language string `json:"language" gorm:"column:language;type:varchar(32);comment:套餐语言 zh-CN zh-TW EN de-DE ja-JP(中繁英德日)"`
|
Language string `json:"language" gorm:"column:language;type:varchar(32);comment:套餐语言 zh-CN zh-TW EN de-DE ja-JP(中繁英德日)"`
|
||||||
PriceType int64 `json:"priceType" gorm:"column:price_type;type:int;comment:币种 1:人民币 2:美元 3:日元 4:欧元"`
|
PriceType int64 `json:"priceType" gorm:"column:price_type;type:int;comment:币种 1:人民币 2:美元 3:日元 4:欧元"`
|
||||||
Options PriceOptions `gorm:"column:options;type:json" json:"options"`
|
Options PriceOptions `gorm:"column:options;type:json" json:"options"`
|
||||||
CreatedAt int64 `gorm:"column:created_at;autoCreateTime"`
|
CreatedAt int64 `gorm:"column:created_at;autoCreateTime"`
|
||||||
UpdatedAt int64 `gorm:"column:updated_at;autoCreateTime"`
|
UpdatedAt int64 `gorm:"column:updated_at;autoCreateTime"`
|
||||||
DeletedAt soft_delete.DeletedAt
|
DeletedAt soft_delete.DeletedAt
|
||||||
|
QuotaType int32 `json:"quotaType" gorm:"column:quota_type;type:int;default:1;comment:额度类型 1:不限额度 2:每月限额度"`
|
||||||
|
QuotaValue int32 `json:"quotaValue" gorm:"column:quota_value;type:int;comment:额度值"`
|
||||||
|
IsExpired bool `json:"isExpired" gorm:"column:is_expired;default:false;comment:是否过期作废 false:不作废 true:作废"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ValueAddServiceHistory struct {
|
type ValueAddServiceHistory struct {
|
||||||
@ -74,11 +77,16 @@ type ValueAddServiceHistory struct {
|
|||||||
|
|
||||||
type PriceOptions []*PriceOption
|
type PriceOptions []*PriceOption
|
||||||
type PriceOption struct {
|
type PriceOption struct {
|
||||||
Id int32 `json:"id"`
|
Id int32 `json:"id"`
|
||||||
Num int32 `json:"num"`
|
Num int32 `json:"num"`
|
||||||
Symbol string `json:"symbol"` // 符号> < = >= <=
|
Symbol string `json:"symbol"` // 符号> < = >= <=
|
||||||
Price float32 `json:"price"` // 价格(根据priceMode决定是单价还是总价)
|
Price float32 `json:"price"` // 价格(根据priceMode决定是单价还是总价)
|
||||||
TotalPrice float32 `json:"totalPrice"` // 总价-新加
|
IsDefault bool `json:"isDefault"` // 是否为默认
|
||||||
|
}
|
||||||
|
|
||||||
|
type ValueUidWithBenefits struct {
|
||||||
|
ValueUid string `json:"valueUid"` //增值服务UUID
|
||||||
|
BenefitsType int32 `json:"benefitsType"` //权益类型
|
||||||
}
|
}
|
||||||
|
|
||||||
// 实现 driver.Valuer 接口
|
// 实现 driver.Valuer 接口
|
||||||
@ -151,7 +159,6 @@ func (m *ValueAddServiceHistory) TableName() string {
|
|||||||
func (options PriceOptions) CalculatePrice(priceMode, target int32) (float32, error) {
|
func (options PriceOptions) CalculatePrice(priceMode, target int32) (float32, error) {
|
||||||
for _, opt := range options {
|
for _, opt := range options {
|
||||||
match := false
|
match := false
|
||||||
last := false
|
|
||||||
switch opt.Symbol {
|
switch opt.Symbol {
|
||||||
case "=":
|
case "=":
|
||||||
match = target == opt.Num
|
match = target == opt.Num
|
||||||
@ -159,7 +166,6 @@ func (options PriceOptions) CalculatePrice(priceMode, target int32) (float32, er
|
|||||||
match = target > opt.Num
|
match = target > opt.Num
|
||||||
case ">=":
|
case ">=":
|
||||||
match = target >= opt.Num
|
match = target >= opt.Num
|
||||||
last = true
|
|
||||||
case "<":
|
case "<":
|
||||||
match = target < opt.Num
|
match = target < opt.Num
|
||||||
case "<=":
|
case "<=":
|
||||||
@ -171,12 +177,6 @@ func (options PriceOptions) CalculatePrice(priceMode, target int32) (float32, er
|
|||||||
if match {
|
if match {
|
||||||
switch priceMode { //1 单价模式
|
switch priceMode { //1 单价模式
|
||||||
case 1:
|
case 1:
|
||||||
if last {
|
|
||||||
return float32(target) * opt.Price, nil
|
|
||||||
}
|
|
||||||
if opt.TotalPrice > 0 {
|
|
||||||
return opt.TotalPrice, nil
|
|
||||||
}
|
|
||||||
return float32(target) * opt.Price, nil
|
return float32(target) * opt.Price, nil
|
||||||
case 2:
|
case 2:
|
||||||
return opt.Price, nil
|
return opt.Price, nil
|
||||||
@ -188,3 +188,9 @@ func (options PriceOptions) CalculatePrice(priceMode, target int32) (float32, er
|
|||||||
|
|
||||||
return 0, fmt.Errorf("未找到匹配规则")
|
return 0, fmt.Errorf("未找到匹配规则")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 额度信息
|
||||||
|
type QuotaInfo struct {
|
||||||
|
QuotaType int32 // 1:不限额度 2:每月限额度
|
||||||
|
QuotaValue int32 // 额度值
|
||||||
|
}
|
||||||
|
@ -254,9 +254,10 @@ message BundleProfile {
|
|||||||
string bgImg2 = 15 [json_name = "bgImg2"];
|
string bgImg2 = 15 [json_name = "bgImg2"];
|
||||||
int64 shelfStatus = 16 [json_name = "shelfStatus"]; // 1 上架 2 下架
|
int64 shelfStatus = 16 [json_name = "shelfStatus"]; // 1 上架 2 下架
|
||||||
repeated SelectValueAddService selectValueAddService = 17 [json_name = "SelectValueAddService"];
|
repeated SelectValueAddService selectValueAddService = 17 [json_name = "SelectValueAddService"];
|
||||||
repeated BundleProfileLang bundleProfileLang = 18 [json_name = "bundleProfileLang"];
|
repeated SelectValueAdditionalService selectValueAdditionalService = 18 [json_name = "SelectValueAdditionalService"];
|
||||||
int32 imgOption = 19 [json_name = "imgOption"];
|
repeated BundleProfileLang bundleProfileLang = 19 [json_name = "bundleProfileLang"];
|
||||||
string fontColor = 20 [json_name = "fontColor"];
|
int32 imgOption = 20 [json_name = "imgOption"];
|
||||||
|
string fontColor = 21 [json_name = "fontColor"];
|
||||||
}
|
}
|
||||||
message BundleProfileLang {
|
message BundleProfileLang {
|
||||||
string uuid = 1 [json_name = "uuid"];
|
string uuid = 1 [json_name = "uuid"];
|
||||||
@ -276,20 +277,45 @@ message BundleProfileLang {
|
|||||||
string bgImg2 = 15 [json_name = "bgImg2"];
|
string bgImg2 = 15 [json_name = "bgImg2"];
|
||||||
int64 shelfStatus = 16 [json_name = "shelfStatus"]; // 1 上架 2 下架
|
int64 shelfStatus = 16 [json_name = "shelfStatus"]; // 1 上架 2 下架
|
||||||
int32 imgOption = 17 [json_name = "imgOption"];
|
int32 imgOption = 17 [json_name = "imgOption"];
|
||||||
|
repeated ServiceLangInfo serviceLangInfo = 18 [json_name = "serviceLangInfo"];//增值服务信息
|
||||||
//repeated ValueAddServiceLang valueAddServiceLang = 12 [json_name = "ValueAddServiceLang"];
|
//repeated ValueAddServiceLang valueAddServiceLang = 12 [json_name = "ValueAddServiceLang"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message ServiceLangInfo {
|
||||||
|
string valueAddUuid = 1 [json_name = "valueAddUuid"];//增值服务uuid
|
||||||
|
int32 benefitsType = 2 [json_name = "benefitsType"];//权益类型 1:套餐权益 2:可选附加权益
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
message SaveResponse {
|
message SaveResponse {
|
||||||
string msg = 1 [json_name = "msg"];
|
string msg = 1 [json_name = "msg"];
|
||||||
string uuid = 2 [json_name = "uuid"];
|
string uuid = 2 [json_name = "uuid"];
|
||||||
int64 cancelNum = 3 [json_name = "cancelNum"];
|
int64 cancelNum = 3 [json_name = "cancelNum"];
|
||||||
}
|
}
|
||||||
|
// 套餐权益
|
||||||
message SelectValueAddService {
|
message SelectValueAddService {
|
||||||
string valueAddUuid = 1 [json_name = "valueAddUuid"];
|
string valueAddUuid = 1 [json_name = "valueAddUuid"];
|
||||||
string serviceName= 2 [json_name = "serviceName"];
|
string serviceName= 2 [json_name = "serviceName"];// 服务名称
|
||||||
bool isDisplay = 3 [json_name = "isDisplay"];
|
bool isDisplay = 3 [json_name = "isDisplay"];// 是否显示
|
||||||
int32 serviceType = 4 [json_name = "serviceType"];
|
int32 serviceType = 4 [json_name = "serviceType"];// 服务类型
|
||||||
|
int32 quotaType = 5 [json_name = "quotaType"];// 额度类型 1;不限额度 2:每月限额度
|
||||||
|
int32 quotaValue = 6 [json_name = "quotaValue"];// 额度值
|
||||||
|
bool isExpired = 7 [json_name = "isExpired"];// 是否过期作废
|
||||||
|
int32 defaultServiceValue = 8 [json_name = "defaultServiceValue"];// 默认服务值
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// 套餐可选附加权益
|
||||||
|
message SelectValueAdditionalService {
|
||||||
|
string valueAddUuid = 1 [json_name = "valueAddUuid"];
|
||||||
|
string serviceName= 2 [json_name = "serviceName"];// 服务名称
|
||||||
|
bool isDisplay = 3 [json_name = "isDisplay"];// 是否显示
|
||||||
|
int32 serviceType = 4 [json_name = "serviceType"];// 服务类型
|
||||||
|
int32 quotaType = 5 [json_name = "quotaType"];// 额度类型 1;不限额度 2:每月限额度
|
||||||
|
int32 quotaValue = 6 [json_name = "quotaValue"];// 额度值
|
||||||
|
bool isExpired = 7 [json_name = "isExpired"];// 是否过期作废
|
||||||
|
int32 defaultServiceValue = 8 [json_name = "defaultServiceValue"];// 默认服务值
|
||||||
|
}
|
||||||
|
|
||||||
message DelBundleRequest {
|
message DelBundleRequest {
|
||||||
string uuid = 1 [json_name = "uuid"];
|
string uuid = 1 [json_name = "uuid"];
|
||||||
}
|
}
|
||||||
@ -501,21 +527,28 @@ 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"]; //不太语言的服务详细
|
||||||
|
int32 quotaType = 5 [json_name = "quotaType"];//额度类型 1;不限额度 2:每月限额度
|
||||||
|
int32 quotaValue = 6 [json_name = "quotaValue"];//额度值
|
||||||
|
bool isExpired = 7 [json_name = "isExpired"];//是否过期作废
|
||||||
|
int32 defaultServiceValue = 8 [json_name = "defaultServiceValue"];//默认服务值
|
||||||
}
|
}
|
||||||
message ValueAddServiceLang {
|
message ValueAddServiceLang {
|
||||||
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"]; //服务类型 1:视频 2:图文 3:数据报表 4:账号数 5:可用时长
|
||||||
int32 priceMode = 4 [json_name = "priceMode"];
|
int32 priceMode = 4 [json_name = "priceMode"]; //套餐价格类型 1:单价 2:总价
|
||||||
string originalPrice = 5 [json_name = "originalPrice"];
|
string originalPrice = 5 [json_name = "originalPrice"];//原单价
|
||||||
string unit = 6 [json_name = "unit"];
|
string unit = 6 [json_name = "unit"];//单位 1:个 2:条 3:天 4:月 5:年 6:自然月 7:自然季度 8:半年 9:自然年
|
||||||
int64 priceType = 7 [json_name = "priceType"];
|
int64 priceType = 7 [json_name = "priceType"];//币种 1:人民币 2:美元 3:日元 4:欧元
|
||||||
string language = 8 [json_name = "language"];
|
string language = 8 [json_name = "language"];//套餐语言 zh-CN zh-TW EN de-DE ja-JP(中繁英德日)
|
||||||
string createdAt = 9 [json_name = "createdAt"];
|
string createdAt = 9 [json_name = "createdAt"];
|
||||||
string updatedAt = 10 [json_name = "updatedAt"];
|
string updatedAt = 10 [json_name = "updatedAt"];
|
||||||
repeated ValueAddPriceOptions options = 12 [json_name = "options"];
|
repeated ValueAddPriceOptions options = 11 [json_name = "options"];
|
||||||
|
int32 quotaType = 12 [json_name = "quotaType"]; //额度类型 1;不限额度 2:每月限额度
|
||||||
|
int32 quotaValue = 13 [json_name = "quotaValue"]; //额度值
|
||||||
|
bool isExpired = 14 [json_name = "isExpired"]; //是否过期作废 false:不作废 true:作废
|
||||||
}
|
}
|
||||||
//增值服务价格选项
|
//增值服务价格选项
|
||||||
message ValueAddPriceOptions {
|
message ValueAddPriceOptions {
|
||||||
@ -524,15 +557,15 @@ message ValueAddPriceOptions {
|
|||||||
string symbol = 3 [json_name = "symbol"];
|
string symbol = 3 [json_name = "symbol"];
|
||||||
string price = 4 [json_name = "price"];
|
string price = 4 [json_name = "price"];
|
||||||
string saveAmount = 5 [json_name = "saveAmount"];
|
string saveAmount = 5 [json_name = "saveAmount"];
|
||||||
string totalPrice = 6 [json_name = "totalPrice"];
|
bool isDefault = 6 [json_name = "isDefault"]; // 是否为默认
|
||||||
|
|
||||||
}
|
}
|
||||||
//增值服务列表
|
//增值服务列表
|
||||||
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"];
|
||||||
@ -707,12 +740,11 @@ message GetUsedRecordListReq{
|
|||||||
string account = 3;
|
string account = 3;
|
||||||
int32 platform = 4;
|
int32 platform = 4;
|
||||||
int32 type = 5;
|
int32 type = 5;
|
||||||
string workTitle = 6;
|
string title = 6;
|
||||||
int64 submitTimeStart = 7;
|
int64 submitTimeStart = 7;
|
||||||
int64 submitTimeEnd = 8;
|
int64 submitTimeEnd = 8;
|
||||||
int32 page = 9;
|
int32 page = 9;
|
||||||
int32 pageSize = 10;
|
int32 pageSize = 10;
|
||||||
int32 costType = 11;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetUsedRecordListResp {
|
message GetUsedRecordListResp {
|
||||||
@ -736,7 +768,6 @@ message WorkCastItem{
|
|||||||
string operatorName = 13; // 操作人名称
|
string operatorName = 13; // 操作人名称
|
||||||
string operatorPhone = 14; // 操作人手机号
|
string operatorPhone = 14; // 操作人手机号
|
||||||
uint32 status = 15; // 1 有效 2 失效
|
uint32 status = 15; // 1 有效 2 失效
|
||||||
uint32 costType = 16;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetImageWorkDetailReq {
|
message GetImageWorkDetailReq {
|
||||||
@ -780,7 +811,6 @@ message workItem{
|
|||||||
int64 createdAt = 11; // 提交时间
|
int64 createdAt = 11; // 提交时间
|
||||||
string artistName = 12;
|
string artistName = 12;
|
||||||
string artistUuid = 13;
|
string artistUuid = 13;
|
||||||
uint32 costType = 14;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message ToBeComfirmedWorksResp{
|
message ToBeComfirmedWorksResp{
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -95,6 +95,13 @@ func (this *BundleProfile) Validate() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for _, item := range this.SelectValueAdditionalService {
|
||||||
|
if item != nil {
|
||||||
|
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
|
||||||
|
return github_com_mwitkow_go_proto_validators.FieldError("SelectValueAdditionalService", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
for _, item := range this.BundleProfileLang {
|
for _, item := range this.BundleProfileLang {
|
||||||
if item != nil {
|
if item != nil {
|
||||||
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
|
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
|
||||||
@ -105,6 +112,16 @@ func (this *BundleProfile) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func (this *BundleProfileLang) Validate() error {
|
func (this *BundleProfileLang) Validate() error {
|
||||||
|
for _, item := range this.ServiceLangInfo {
|
||||||
|
if item != nil {
|
||||||
|
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
|
||||||
|
return github_com_mwitkow_go_proto_validators.FieldError("ServiceLangInfo", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (this *ServiceLangInfo) Validate() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func (this *SaveResponse) Validate() error {
|
func (this *SaveResponse) Validate() error {
|
||||||
@ -113,6 +130,9 @@ func (this *SaveResponse) Validate() error {
|
|||||||
func (this *SelectValueAddService) Validate() error {
|
func (this *SelectValueAddService) Validate() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
func (this *SelectValueAdditionalService) Validate() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
func (this *DelBundleRequest) Validate() error {
|
func (this *DelBundleRequest) Validate() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-go-triple. DO NOT EDIT.
|
// Code generated by protoc-gen-go-triple. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// - protoc-gen-go-triple v1.0.8
|
// - protoc-gen-go-triple v1.0.5
|
||||||
// - protoc v3.12.4
|
// - protoc v5.26.0
|
||||||
// source: pb/bundle.proto
|
// source: pb/bundle.proto
|
||||||
|
|
||||||
package bundle
|
package bundle
|
||||||
|
@ -18,6 +18,11 @@ const (
|
|||||||
JA_JP = "ja-JP" //日语
|
JA_JP = "ja-JP" //日语
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
Benefits = 1 //套餐权益
|
||||||
|
OptionalBenefits = 2 //套餐可选附加权益
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Http = 200
|
Http = 200
|
||||||
OriginalPrice = 3500 // 注意!!!这边是原始价格如果发生更改,则默认增值套餐需要停用,并且新增新的增值套餐(功能未做)
|
OriginalPrice = 3500 // 注意!!!这边是原始价格如果发生更改,则默认增值套餐需要停用,并且新增新的增值套餐(功能未做)
|
||||||
@ -100,3 +105,18 @@ const (
|
|||||||
ErrorValueServicePriceModeEmpty = "增值服务价格模式不能为空"
|
ErrorValueServicePriceModeEmpty = "增值服务价格模式不能为空"
|
||||||
ErrorValueServiceOptionsEmpty = "增值服务选项不能为空"
|
ErrorValueServiceOptionsEmpty = "增值服务选项不能为空"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// 服务额度信息
|
||||||
|
const (
|
||||||
|
UnlimitedQuota = 1 //不限额度
|
||||||
|
LimitedQuota = 2 //限制额度
|
||||||
|
)
|
||||||
|
|
||||||
|
// 服务类型
|
||||||
|
const (
|
||||||
|
VideoService = 1 //视频
|
||||||
|
TextService = 2 //图文
|
||||||
|
DataReportService = 3 //数据报表
|
||||||
|
AccountService = 4 //账号数
|
||||||
|
AvailableTimeService = 5 //可用时长
|
||||||
|
)
|
||||||
|
3
protocBundle.bat
Normal file
3
protocBundle.bat
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
@echo off
|
||||||
|
protoc -I . -I ./pb --proto_path=./pb --go_out=./pb --go-triple_out=./pb --govalidators_out=./pb ./pb/bundle.proto
|
||||||
|
.\clear.sh
|
Loading…
Reference in New Issue
Block a user