Updata:区分套餐权益和附加权益

This commit is contained in:
jiaji.H 2025-09-11 14:54:21 +08:00
parent 4d42019882
commit 9635ec4572
6 changed files with 1913 additions and 1763 deletions

View File

@ -163,12 +163,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,25 +199,26 @@ 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,
}) })
} }
} }

View File

@ -116,23 +116,36 @@ func SaveBundle(req *bundle.BundleProfile) (res *bundle.SaveResponse, err error)
return res, errors.New("查询增值服务失败") return res, errors.New("查询增值服务失败")
} }
} }
switch v.BenefitsType { if _, exists := pkgBenefitsValueAddServiceCount[int(detail.ServiceType)]; exists {
case 1: return res, errors.New("每种增值服务类型只可选择一个")
if _, exists := pkgBenefitsValueAddServiceCount[int(detail.ServiceType)]; exists { }
return res, errors.New("每种增值服务类型只可选择一个") 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 {
for _, v := range req.SelectValueAdditionalService {
detail, checkErr := dao.ValueAddServiceDetailByUuidAndLanguage(v.ValueAddUuid, req.Language)
if checkErr != nil {
if checkErr == gorm.ErrRecordNotFound {
return res, errors.New("增值服务不存在")
} else {
return res, errors.New("查询增值服务失败")
}
} }
pkgBenefitsValueAddServiceCount[int(detail.ServiceType)] = struct{}{}
case 2:
if _, exists := pkgOptionalValueAddServiceCount[int(detail.ServiceType)]; exists { if _, exists := pkgOptionalValueAddServiceCount[int(detail.ServiceType)]; exists {
return res, errors.New("每种增值服务类型只可选择一个") return res, errors.New("每种增值服务类型只可选择一个")
} }
pkgOptionalValueAddServiceCount[int(detail.ServiceType)] = struct{}{} pkgOptionalValueAddServiceCount[int(detail.ServiceType)] = struct{}{}
selectService = append(selectService, &model.BundleToValueAddService{
ValueUid: v.ValueAddUuid,
IsDisplay: v.IsDisplay,
BenefitsType: msg.OptionalBenefits,
})
} }
selectService = append(selectService, &model.BundleToValueAddService{
ValueUid: v.ValueAddUuid,
IsDisplay: v.IsDisplay,
BenefitsType: v.BenefitsType,
})
} }
} }
tx := app.ModuleClients.BundleDB.Begin() tx := app.ModuleClients.BundleDB.Begin()

View File

@ -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"];
@ -283,14 +284,21 @@ message SaveResponse {
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 benefitsType = 5 [json_name = "benefitsType"]; // 1: 2:
} }
//
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"];//
}
message DelBundleRequest { message DelBundleRequest {
string uuid = 1 [json_name = "uuid"]; string uuid = 1 [json_name = "uuid"];
} }

File diff suppressed because it is too large Load Diff

View File

@ -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 {
@ -113,6 +120,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
} }

View File

@ -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 // 注意!!!这边是原始价格如果发生更改,则默认增值套餐需要停用,并且新增新的增值套餐(功能未做)