Updata:区分套餐权益和附加权益
This commit is contained in:
parent
4d42019882
commit
9635ec4572
@ -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 {
|
||||
selectValueAddService = append(selectValueAddService, &bundle.SelectValueAddService{
|
||||
ValueAddUuid: v.ValueUid,
|
||||
IsDisplay: v.IsDisplay,
|
||||
})
|
||||
//根据权益类型存入对应的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{}
|
||||
@ -188,25 +199,26 @@ func BundleListV2(req *bundle.BundleListRequest) (res *bundle.BundleListResponse
|
||||
}
|
||||
}
|
||||
res.Bundles = append(res.Bundles, &bundle.BundleProfile{
|
||||
Uuid: bundleProfile.UUID,
|
||||
Name: bundleProfile.Name,
|
||||
Content: bundleProfile.Content,
|
||||
Price: bundleProfile.Price,
|
||||
PriceType: bundleProfile.PriceType,
|
||||
Contract: bundleProfile.Contract,
|
||||
Language: bundleProfile.Language,
|
||||
CreatedAt: bundleProfile.CreatedAt.Format("2006-01-02 15:04:05"),
|
||||
UpdatedAt: bundleProfile.UpdatedAt.Format("2006-01-02 15:04:05"),
|
||||
CompanySign: bundleProfile.CompanySign,
|
||||
ContractDuration: int64(bundleProfile.ContractDuration),
|
||||
Sort: bundleProfile.Sort,
|
||||
ImgOption: int32(bundleProfile.ImgOption),
|
||||
BgImg1: bundleProfile.BgImg1,
|
||||
BgImg2: bundleProfile.BgImg2,
|
||||
SelectValueAddService: selectValueAddService,
|
||||
BundleProfileLang: bundleProfileLang,
|
||||
ShelfStatus: int64(bundleProfile.ShelfStatus),
|
||||
FontColor: bundleProfile.FontColor,
|
||||
Uuid: bundleProfile.UUID,
|
||||
Name: bundleProfile.Name,
|
||||
Content: bundleProfile.Content,
|
||||
Price: bundleProfile.Price,
|
||||
PriceType: bundleProfile.PriceType,
|
||||
Contract: bundleProfile.Contract,
|
||||
Language: bundleProfile.Language,
|
||||
CreatedAt: bundleProfile.CreatedAt.Format("2006-01-02 15:04:05"),
|
||||
UpdatedAt: bundleProfile.UpdatedAt.Format("2006-01-02 15:04:05"),
|
||||
CompanySign: bundleProfile.CompanySign,
|
||||
ContractDuration: int64(bundleProfile.ContractDuration),
|
||||
Sort: bundleProfile.Sort,
|
||||
ImgOption: int32(bundleProfile.ImgOption),
|
||||
BgImg1: bundleProfile.BgImg1,
|
||||
BgImg2: bundleProfile.BgImg2,
|
||||
SelectValueAddService: selectValueAddService,
|
||||
SelectValueAdditionalService: SelectValueAdditionalService,
|
||||
BundleProfileLang: bundleProfileLang,
|
||||
ShelfStatus: int64(bundleProfile.ShelfStatus),
|
||||
FontColor: bundleProfile.FontColor,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -116,23 +116,36 @@ 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("每种增值服务类型只可选择一个")
|
||||
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 {
|
||||
return res, errors.New("每种增值服务类型只可选择一个")
|
||||
}
|
||||
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()
|
||||
|
@ -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
@ -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
|
||||
}
|
||||
|
@ -18,6 +18,11 @@ const (
|
||||
JA_JP = "ja-JP" //日语
|
||||
)
|
||||
|
||||
const (
|
||||
Benefits = 1 //套餐权益
|
||||
OptionalBenefits = 2 //套餐可选附加权益
|
||||
)
|
||||
|
||||
const (
|
||||
Http = 200
|
||||
OriginalPrice = 3500 // 注意!!!这边是原始价格如果发生更改,则默认增值套餐需要停用,并且新增新的增值套餐(功能未做)
|
||||
|
Loading…
Reference in New Issue
Block a user