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 {
for _, bundleProfile := range bundles {
selectValueAddService := make([]*bundle.SelectValueAddService, 0)
SelectValueAdditionalService := make([]*bundle.SelectValueAdditionalService, 0)
if bundleProfile.BundleToValueAddService != nil {
for _, v := range bundleProfile.BundleToValueAddService {
//根据权益类型存入对应的list
switch v.BenefitsType {
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{}
@ -204,6 +215,7 @@ func BundleListV2(req *bundle.BundleListRequest) (res *bundle.BundleListResponse
BgImg1: bundleProfile.BgImg1,
BgImg2: bundleProfile.BgImg2,
SelectValueAddService: selectValueAddService,
SelectValueAdditionalService: SelectValueAdditionalService,
BundleProfileLang: bundleProfileLang,
ShelfStatus: int64(bundleProfile.ShelfStatus),
FontColor: bundleProfile.FontColor,

View File

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

View File

@ -254,9 +254,10 @@ message BundleProfile {
string bgImg2 = 15 [json_name = "bgImg2"];
int64 shelfStatus = 16 [json_name = "shelfStatus"]; // 1 2
repeated SelectValueAddService selectValueAddService = 17 [json_name = "SelectValueAddService"];
repeated BundleProfileLang bundleProfileLang = 18 [json_name = "bundleProfileLang"];
int32 imgOption = 19 [json_name = "imgOption"];
string fontColor = 20 [json_name = "fontColor"];
repeated SelectValueAdditionalService selectValueAdditionalService = 18 [json_name = "SelectValueAdditionalService"];
repeated BundleProfileLang bundleProfileLang = 19 [json_name = "bundleProfileLang"];
int32 imgOption = 20 [json_name = "imgOption"];
string fontColor = 21 [json_name = "fontColor"];
}
message BundleProfileLang {
string uuid = 1 [json_name = "uuid"];
@ -283,14 +284,21 @@ message SaveResponse {
string uuid = 2 [json_name = "uuid"];
int64 cancelNum = 3 [json_name = "cancelNum"];
}
//
message SelectValueAddService {
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 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 {
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 {
if item != 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 {
return nil
}
func (this *SelectValueAdditionalService) Validate() error {
return nil
}
func (this *DelBundleRequest) Validate() error {
return nil
}

View File

@ -18,6 +18,11 @@ const (
JA_JP = "ja-JP" //日语
)
const (
Benefits = 1 //套餐权益
OptionalBenefits = 2 //套餐可选附加权益
)
const (
Http = 200
OriginalPrice = 3500 // 注意!!!这边是原始价格如果发生更改,则默认增值套餐需要停用,并且新增新的增值套餐(功能未做)