Compare commits
	
		
			5 Commits
		
	
	
		
			a515beee31
			...
			010b775b0b
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 010b775b0b | |||
| 6b07fe383f | |||
| 558d322847 | |||
| e8dd695efd | |||
| 7a065f487d | 
							
								
								
									
										35
									
								
								internal/controller/bundleV2.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								internal/controller/bundleV2.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,35 @@ | ||||
| package controller | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"micro-bundle/internal/logic" | ||||
| 	"micro-bundle/pb/bundle" | ||||
| ) | ||||
| 
 | ||||
| func (b *BundleProvider) SaveBundle(_ context.Context, req *bundle.BundleProfile) (res *bundle.SaveResponse, err error) { | ||||
| 	return logic.SaveBundle(req) | ||||
| } | ||||
| 
 | ||||
| // 上下架状态更新
 | ||||
| func (b *BundleProvider) HandShelf(_ context.Context, req *bundle.HandShelfRequest) (res *bundle.CommonResponse, err error) { | ||||
| 	// shelfStatus: 1-上架,2-下架
 | ||||
| 	return logic.HandShelf(req) | ||||
| } | ||||
| func (b *BundleProvider) BundleListV2(_ context.Context, req *bundle.BundleListRequest) (res *bundle.BundleListResponse, err error) { | ||||
| 	return logic.BundleListV2(req) | ||||
| } | ||||
| 
 | ||||
| func (b *BundleProvider) BundleDetailV2(_ context.Context, req *bundle.BundleDetailRequest) (res *bundle.BundleDetailResponseV2, err error) { | ||||
| 	return logic.BundleDetailV2(req) | ||||
| } | ||||
| 
 | ||||
| // ***************************************************新增值服务***********************
 | ||||
| func (b *BundleProvider) SaveValueAddService(_ context.Context, req *bundle.ValueAddServiceLang) (res *bundle.SaveResponse, err error) { | ||||
| 	return logic.SaveValueAddService(req) | ||||
| } | ||||
| func (b *BundleProvider) ValueAddServiceList(_ context.Context, req *bundle.ValueAddServiceListRequest) (res *bundle.ValueAddServiceListResponse, err error) { | ||||
| 	return logic.ValueAddServiceList(req) | ||||
| } | ||||
| func (b *BundleProvider) ValueAddServiceDetail(_ context.Context, req *bundle.ValueAddServiceDetailRequest) (res *bundle.ValueAddServiceDetailResponse, err error) { | ||||
| 	return logic.ValueAddServiceDetail(req) | ||||
| } | ||||
| @ -1,11 +1,16 @@ | ||||
| package dao | ||||
| 
 | ||||
| import ( | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"micro-bundle/internal/model" | ||||
| 	"micro-bundle/pb/bundle" | ||||
| 	"micro-bundle/pkg/app" | ||||
| 	commonErr "micro-bundle/pkg/err" | ||||
| 	"micro-bundle/pkg/msg" | ||||
| 	"time" | ||||
| 
 | ||||
| 	"gorm.io/gorm" | ||||
| ) | ||||
| 
 | ||||
| func CreateBundle(req *model.BundleProfile) (res *bundle.CommonResponse, err error) { | ||||
| @ -21,7 +26,7 @@ func CreateBundle(req *model.BundleProfile) (res *bundle.CommonResponse, err err | ||||
| 
 | ||||
| func UpdateBundle(req *model.BundleProfile) (res *bundle.CommonResponse, err error) { | ||||
| 	res = new(bundle.CommonResponse) | ||||
| 	err = app.ModuleClients.BundleDB.Model(&model.BundleProfile{}).Where("uuid = ?", req.UUID).Updates(req).Error | ||||
| 	err = app.ModuleClients.BundleDB.Model(&model.BundleProfile{}).Where("uuid = ? and language= ?", req.UUID, req.Language).Updates(req).Error | ||||
| 	if err != nil { | ||||
| 		res.Msg = msg.ErrorUpdateBundleInfo | ||||
| 		return res, commonErr.ReturnError(err, msg.ErrorUpdateBundleInfo, "更新套餐信息失败: ") | ||||
| @ -126,3 +131,258 @@ func BundleDetail(uuid string) (res *bundle.BundleProfile, err error) { | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
| 
 | ||||
| func BundleListV2(req *bundle.BundleListRequest) (res *bundle.BundleListResponse, err error) { | ||||
| 	res = new(bundle.BundleListResponse) | ||||
| 	res.Bundles = make([]*bundle.BundleProfile, 0) | ||||
| 	bundles := make([]*model.BundleProfile, 0) | ||||
| 
 | ||||
| 	query := app.ModuleClients.BundleDB.Model(&model.BundleProfile{}).Preload("BundleProfileLang") | ||||
| 	//query = query.Where("shelf_status = ?", 1) //上架的
 | ||||
| 
 | ||||
| 	if req.Name != "" { | ||||
| 		query = query.Where("name like ?", "%"+req.Name+"%") | ||||
| 	} | ||||
| 
 | ||||
| 	if req.Content != "" { | ||||
| 		query = query.Where("content like ?", "%"+req.Content+"%") | ||||
| 	} | ||||
| 
 | ||||
| 	if req.Language != "" { | ||||
| 		query = query.Where("language like ?", req.Language) | ||||
| 	} | ||||
| 
 | ||||
| 	count := *query | ||||
| 
 | ||||
| 	// 排序:sort 升序,相同 sort 按 created_at 倒序
 | ||||
| 	query = query.Order("sort ASC").Order("created_at DESC") | ||||
| 	if req.PageSize != 0 && req.Page != 0 { | ||||
| 		query = query.Limit(int(req.PageSize)).Offset(int(req.Page-1) * int(req.PageSize)) | ||||
| 	} | ||||
| 
 | ||||
| 	if err = query.Find(&bundles).Error; err != nil { | ||||
| 		return res, commonErr.ReturnError(err, msg.ErrorGetBundleList, "获取套餐列表失败: ") | ||||
| 	} | ||||
| 	if bundles != nil && len(bundles) > 0 { | ||||
| 		for _, bundleProfile := range bundles { | ||||
| 			selectValueAddService := make([]*bundle.SelectValueAddService, 0) | ||||
| 			// 通过中间表拼接增值服务数据
 | ||||
| 			if bundleProfile.UUID != "" { | ||||
| 				bundleToValueAddServices, err := GetBundleToValueAddServiceByBundleUuid(bundleProfile.UUID) | ||||
| 				if err != nil { | ||||
| 					return res, commonErr.ReturnError(err, msg.ErrorGetBundleInfo, "获取增值服务信息失败: ") | ||||
| 				} | ||||
| 				for _, v := range bundleToValueAddServices { | ||||
| 					valueAddDetail, _ := ValueAddServiceDetail(v.ValueUid, "") | ||||
| 					selectValueAddService = append(selectValueAddService, &bundle.SelectValueAddService{ | ||||
| 						ValueAddUuid: v.ValueUid, | ||||
| 						IsDisplay:    v.IsDisplay, | ||||
| 						ServiceName:  valueAddDetail.ServiceName, | ||||
| 					}) | ||||
| 				} | ||||
| 			} | ||||
| 			bundleProfileLang := []*bundle.BundleProfileLang{} | ||||
| 			if bundleProfile.BundleProfileLang != nil && len(bundleProfile.BundleProfileLang) > 0 { | ||||
| 				for _, lang := range bundleProfile.BundleProfileLang { | ||||
| 					bpl := &bundle.BundleProfileLang{ | ||||
| 						Uuid:      lang.UUID, | ||||
| 						Name:      lang.Name, | ||||
| 						Price:     lang.Price, | ||||
| 						PriceType: lang.PriceType, | ||||
| 						Content:   lang.Content, | ||||
| 						Language:  lang.Language, | ||||
| 						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"), | ||||
| 					} | ||||
| 					bundleProfileLang = append(bundleProfileLang, bpl) | ||||
| 				} | ||||
| 			} | ||||
| 			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, | ||||
| 				BgImg1:                bundleProfile.BgImg1, | ||||
| 				BgImg2:                bundleProfile.BgImg2, | ||||
| 				SelectValueAddService: selectValueAddService, | ||||
| 				BundleProfileLang:     bundleProfileLang, | ||||
| 				ShelfStatus:           int64(bundleProfile.ShelfStatus), | ||||
| 			}) | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	var total int64 | ||||
| 
 | ||||
| 	count.Count(&total) | ||||
| 
 | ||||
| 	res.Total = int32(total) | ||||
| 
 | ||||
| 	return | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| func BundleDetailV2(req *bundle.BundleDetailRequest) (res *bundle.BundleDetailResponseV2, err error) { | ||||
| 	if req.Uuid == "" { | ||||
| 		return res, errors.New("uuid不能为空") | ||||
| 	} | ||||
| 	if req.Language == "" { | ||||
| 		return res, errors.New("language不能为空") | ||||
| 	} | ||||
| 	res = new(bundle.BundleDetailResponseV2) | ||||
| 	bundleProfile := new(model.BundleProfile) | ||||
| 	err = app.ModuleClients.BundleDB.Model(&model.BundleProfile{}).Where("uuid = ?", req.Uuid).Preload("BundleProfileLang").First(&bundleProfile).Error | ||||
| 	if err != nil { | ||||
| 		return res, commonErr.ReturnError(err, msg.ErrorGetBundleInfo, "获取套餐信息失败: ") | ||||
| 	} | ||||
| 	bundleProfileLang := &bundle.BundleProfileLang{ | ||||
| 		BgImg1: bundleProfile.BgImg1, | ||||
| 		BgImg2: bundleProfile.BgImg2, | ||||
| 		Sort:   bundleProfile.Sort, | ||||
| 	} | ||||
| 	if bundleProfile != nil && bundleProfile.BundleProfileLang != nil && len(bundleProfile.BundleProfileLang) > 0 { | ||||
| 		for _, lang := range bundleProfile.BundleProfileLang { | ||||
| 			if lang.Language == req.Language { | ||||
| 				bundleProfileLang = &bundle.BundleProfileLang{ | ||||
| 					Uuid:      lang.UUID, | ||||
| 					Name:      lang.Name, | ||||
| 					Price:     lang.Price, | ||||
| 					PriceType: lang.PriceType, | ||||
| 					Content:   lang.Content, | ||||
| 					Language:  lang.Language, | ||||
| 					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"), | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	selectValueAddService := make([]*bundle.SelectValueAddService, 0) //已选增值服务
 | ||||
| 	// 通过中间表拼接增值服务数据
 | ||||
| 	if bundleProfile.UUID != "" { | ||||
| 		bundleToValueAddServices, err := GetBundleToValueAddServiceByBundleUuid(bundleProfile.UUID) | ||||
| 		if err != nil { | ||||
| 			return res, commonErr.ReturnError(err, msg.ErrorGetBundleInfo, "获取增值服务信息失败: ") | ||||
| 		} | ||||
| 		for _, valueAddService := range bundleToValueAddServices { | ||||
| 			valueAddDeatilData, err := ValueAddServiceDetailByUuidAndLanguage(valueAddService.ValueUid, req.Language) | ||||
| 			if err != nil { | ||||
| 				return res, commonErr.ReturnError(err, msg.ErrorGetBundleInfo, "获取增值服务信息失败: ") | ||||
| 			} | ||||
| 			//if valueAddService.IsDisplay{}
 | ||||
| 			ValueAddServiceLang := &bundle.ValueAddServiceLang{ | ||||
| 				Uuid:          valueAddDeatilData.UUID, | ||||
| 				ServiceName:   valueAddDeatilData.ServiceName, | ||||
| 				ServiceType:   int32(valueAddDeatilData.ServiceType), | ||||
| 				PriceMode:     int32(valueAddDeatilData.PriceMode), | ||||
| 				PriceType:     int64(valueAddDeatilData.PriceType), | ||||
| 				OriginalPrice: fmt.Sprintf("%.2f", float32(valueAddDeatilData.OriginalPrice)), | ||||
| 				Unit:          string(valueAddDeatilData.Unit), | ||||
| 				Language:      valueAddDeatilData.Language, | ||||
| 				CreatedAt:     time.Unix(valueAddDeatilData.CreatedAt, 0).Format("2006-01-02 15:04:05"), | ||||
| 				UpdatedAt:     time.Unix(valueAddDeatilData.UpdatedAt, 0).Format("2006-01-02 15:04:05"), | ||||
| 			} | ||||
| 			bundleProfileLang.ValueAddServiceLang = append(bundleProfileLang.ValueAddServiceLang, ValueAddServiceLang) | ||||
| 			selectValueAddService = append(selectValueAddService, &bundle.SelectValueAddService{ | ||||
| 				ValueAddUuid: valueAddService.ValueUid, | ||||
| 				ServiceName:  valueAddDeatilData.ServiceName, | ||||
| 				IsDisplay:    valueAddService.IsDisplay, | ||||
| 			}) | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	if selectValueAddService != nil && len(selectValueAddService) > 0 { | ||||
| 		res.SelectValueAddService = selectValueAddService | ||||
| 	} | ||||
| 	res.Bundle = bundleProfileLang | ||||
| 	return | ||||
| } | ||||
| 
 | ||||
| // 套餐上下架
 | ||||
| func HandShelf(uuid string, shelfStatus int64) (res *bundle.CommonResponse, err error) { | ||||
| 	res = new(bundle.CommonResponse) | ||||
| 	err = app.ModuleClients.BundleDB.Model(&model.BundleProfile{}).Where("uuid = ?", uuid).Update("shelf_status", shelfStatus).Error | ||||
| 	if err != nil { | ||||
| 		res.Msg = "套餐上下架操作失败" | ||||
| 		return res, err | ||||
| 	} | ||||
| 	res.Msg = "套餐上下架操作成功" | ||||
| 	return res, nil | ||||
| } | ||||
| 
 | ||||
| // 通过uuid和language查询套餐语言表
 | ||||
| func BundleDetailByUuidAndLanguage(uuid string, language string) (bundleProfileLang *model.BundleProfileLang, err error) { | ||||
| 	err = app.ModuleClients.BundleDB.Where("uuid = ? AND language = ?", uuid, language).First(&bundleProfileLang).Error | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
| 
 | ||||
| // 套餐主表创建
 | ||||
| func TxCreateBundle(tx *gorm.DB, req *model.BundleProfile) (err error) { | ||||
| 	err = tx.Model(&model.BundleProfile{}).Create(&req).Error | ||||
| 	if err != nil { | ||||
| 		return commonErr.ReturnError(err, msg.ErrorCreateBundleInfo, "创建套餐信息失败: ") | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
| 
 | ||||
| // 套餐语言表创建
 | ||||
| func TxCreateBundleLang(tx *gorm.DB, req *model.BundleProfileLang) (err error) { | ||||
| 	err = tx.Model(&model.BundleProfileLang{}).Create(&req).Error | ||||
| 	if err != nil { | ||||
| 		return commonErr.ReturnError(err, msg.ErrorCreateBundleInfo, "创建套餐信息失败: ") | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
| func TxUpdateBundle(tx *gorm.DB, uuid string, columns map[string]interface{}) (err error) { | ||||
| 	err = tx.Model(&model.BundleProfile{}).Where("uuid =?", uuid).Updates(columns).Error | ||||
| 	if err != nil { | ||||
| 		return commonErr.ReturnError(err, msg.ErrorUpdateBundleInfo, "更新套餐信息失败: ") | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
| func TxUpdateBundleLang(tx *gorm.DB, uuid string, language string, columns map[string]interface{}) (err error) { | ||||
| 	err = tx.Model(&model.BundleProfileLang{}).Where("uuid =? and language=?", uuid, language).Updates(columns).Error | ||||
| 	if err != nil { | ||||
| 		return commonErr.ReturnError(err, msg.ErrorUpdateBundleInfo, "更新套餐信息失败: ") | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
| func CreateBundleToValueAddService(tx *gorm.DB, records []*model.BundleToValueAddService) error { | ||||
| 	return tx.Model(&model.BundleToValueAddService{}).Create(&records).Error | ||||
| } | ||||
| 
 | ||||
| func DeleteBundleToValueAddService(tx *gorm.DB, bundleUuid, valueUid string) error { | ||||
| 	return tx.Where("bundle_uuid = ? AND value_uid = ?", bundleUuid, valueUid).Delete(&model.BundleToValueAddService{}).Error | ||||
| } | ||||
| func GetValueAddServiceUuidsByBundleUuid(bundleUuid string) ([]string, error) { | ||||
| 	var uuids []string | ||||
| 	err := app.ModuleClients.BundleDB.Model(&model.BundleToValueAddService{}).Where("bundle_uuid = ?", bundleUuid).Pluck("value_uid", &uuids).Error | ||||
| 	return uuids, err | ||||
| } | ||||
| 
 | ||||
| // GetBundleToValueAddServiceByBundleUuid 根据套餐UUID获取所有关联的增值服务uuid
 | ||||
| func GetBundleToValueAddServiceByBundleUuid(bundleUuid string) ([]*model.BundleToValueAddService, error) { | ||||
| 	var result []*model.BundleToValueAddService | ||||
| 	err := app.ModuleClients.BundleDB.Model(&model.BundleToValueAddService{}). | ||||
| 		Where("bundle_uuid = ?", bundleUuid). | ||||
| 		Find(&result).Error | ||||
| 	return result, err | ||||
| } | ||||
| 
 | ||||
| func GetBundleLangsByUuid(uuid string) ([]*model.BundleProfileLang, error) { | ||||
| 	var result []*model.BundleProfileLang | ||||
| 	err := app.ModuleClients.BundleDB.Model(&model.BundleProfileLang{}). | ||||
| 		Where("uuid =?", uuid). | ||||
| 		Find(&result).Error | ||||
| 	return result, err | ||||
| } | ||||
|  | ||||
| @ -99,7 +99,7 @@ func OrderRecordsList(req *bundle.OrderRecordsRequest) (res *bundle.OrderRecords | ||||
| 	} | ||||
| 
 | ||||
| 	if req.Status != 0 { | ||||
| 		query = query.Where("status = ?", req.Status) | ||||
| 		query = query.Where("`bundle_order_records`.status = ?", req.Status) | ||||
| 	} | ||||
| 
 | ||||
| 	if req.StartSignedTime != "" { | ||||
|  | ||||
| @ -2,7 +2,10 @@ package dao | ||||
| 
 | ||||
| import ( | ||||
| 	"micro-bundle/internal/model" | ||||
| 	"micro-bundle/pb/bundle" | ||||
| 	"micro-bundle/pkg/app" | ||||
| 
 | ||||
| 	"gorm.io/gorm" | ||||
| ) | ||||
| 
 | ||||
| // 增值套餐创建
 | ||||
| @ -73,3 +76,84 @@ func GetBundleOrderRecordsByCommonUidAndUserId(commonUid string, userId int32) ( | ||||
| 
 | ||||
| 	return | ||||
| } | ||||
| 
 | ||||
| // ***************************************新增值服务*****************************
 | ||||
| // 增值套餐主表创建
 | ||||
| func CreateValueAddService(tx *gorm.DB, req *model.ValueAddService) (err error) { | ||||
| 	if err := tx.Model(&model.ValueAddService{}).Create(req).Error; err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
| 
 | ||||
| // 增值套餐语言表创建
 | ||||
| func CreateValueAddServiceLang(tx *gorm.DB, req *model.ValueAddServiceLang) (err error) { | ||||
| 	if err := tx.Model(&model.ValueAddServiceLang{}).Create(req).Error; err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
| 
 | ||||
| // 增值套餐主表更新
 | ||||
| func UpdateValueAddService(tx *gorm.DB, columns map[string]interface{}) (err error) { | ||||
| 	err = tx.Model(&model.ValueAddService{}).Where("uuid = ?", columns["uuid"]).Updates(columns).Error | ||||
| 	if err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
| func UpdateValueAddServiceLang(tx *gorm.DB, columns map[string]interface{}) (err error) { | ||||
| 	err = tx.Model(&model.ValueAddServiceLang{}).Where("uuid =?", columns["uuid"]). | ||||
| 		Where("language", columns["language"]).Updates(columns).Error | ||||
| 	if err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
| 
 | ||||
| // 增值套餐列表
 | ||||
| func ValueAddServiceList(req *bundle.ValueAddServiceListRequest) (res []*model.ValueAddService, total int64, err error) { | ||||
| 	query := app.ModuleClients.BundleDB.Model(&model.ValueAddService{}).Preload("ValueAddServiceLang") | ||||
| 	// 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")
 | ||||
| 	// })
 | ||||
| 
 | ||||
| 	count := *query | ||||
| 	if req.PageSize != 0 && req.Page != 0 { | ||||
| 		query = query.Limit(int(req.PageSize)).Offset(int(req.Page-1) * int(req.PageSize)) | ||||
| 	} | ||||
| 	if err = query.Find(&res).Error; err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	// 统计不同uuid的数量
 | ||||
| 	err = count.Select("uuid").Group("uuid").Count(&total).Error | ||||
| 	return | ||||
| } | ||||
| 
 | ||||
| // 增值套餐详情
 | ||||
| func ValueAddServiceDetail(uuid string, language string) (valueAddServiceDetail *model.ValueAddService, err error) { | ||||
| 	var data model.ValueAddService | ||||
| 	err = app.ModuleClients.BundleDB.Where("uuid = ?", uuid).Preload("ValueAddServiceLang").First(&data).Error | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return &data, nil | ||||
| } | ||||
| 
 | ||||
| // 通过uuid和language查询增值套餐
 | ||||
| func ValueAddServiceDetailByUuidAndLanguage(uuid string, language string) (valueAddServiceLang *model.ValueAddServiceLang, err error) { | ||||
| 	err = app.ModuleClients.BundleDB.Where("uuid = ? AND language = ?", uuid, language).First(&valueAddServiceLang).Error | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
| 
 | ||||
| // 通过增值服务UUID查询所有关联套餐
 | ||||
| func GetBundleToValueAddServiceByValueUid(valueUid string) ([]model.BundleToValueAddService, error) { | ||||
| 	var rels []model.BundleToValueAddService | ||||
| 	err := app.ModuleClients.BundleDB.Model(&model.BundleToValueAddService{}). | ||||
| 		Where("value_uid = ?", valueUid). | ||||
| 		Find(&rels).Error | ||||
| 	return rels, err | ||||
| } | ||||
|  | ||||
| @ -1,9 +1,15 @@ | ||||
| package logic | ||||
| 
 | ||||
| import ( | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"micro-bundle/internal/dao" | ||||
| 	"micro-bundle/pkg/app" | ||||
| 	"micro-bundle/pkg/msg" | ||||
| 
 | ||||
| 	"github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils" | ||||
| 	"github.com/jinzhu/copier" | ||||
| 	"micro-bundle/internal/dao" | ||||
| 	"gorm.io/gorm" | ||||
| 
 | ||||
| 	"micro-bundle/internal/model" | ||||
| 	"micro-bundle/pb/bundle" | ||||
| @ -47,3 +53,312 @@ func BundleDetail(req *bundle.BundleDetailRequest) (res *bundle.BundleDetailResp | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
| 
 | ||||
| func SaveBundle(req *bundle.BundleProfile) (res *bundle.SaveResponse, err error) { | ||||
| 	res = &bundle.SaveResponse{} | ||||
| 	if req.Language == "" { | ||||
| 		return res, errors.New("语言参数不能为空") | ||||
| 	} | ||||
| 	if req.Sort <= 0 { | ||||
| 		return res, errors.New("排序参数需为正整数") | ||||
| 	} | ||||
| 	bundleProfile := &model.BundleProfile{ | ||||
| 		Name:        req.Name, | ||||
| 		Sort:        req.Sort, | ||||
| 		Content:     req.Content, | ||||
| 		Price:       req.Price, | ||||
| 		PriceType:   req.PriceType, | ||||
| 		BgImg1:      req.BgImg1, | ||||
| 		BgImg2:      req.BgImg2, | ||||
| 		ShelfStatus: 2, //默认初始状态为2-下架
 | ||||
| 	} | ||||
| 	bundleLang := &model.BundleProfileLang{ | ||||
| 		Name:      req.Name, | ||||
| 		Content:   req.Content, | ||||
| 		Price:     req.Price, | ||||
| 		PriceType: req.PriceType, | ||||
| 		Language:  req.Language, | ||||
| 	} | ||||
| 	if req.Uuid == "" && req.Language != msg.ZH_CN { | ||||
| 		return res, errors.New("请先创建中文版本套餐") | ||||
| 	} | ||||
| 	var existValueService = make(map[string]string) | ||||
| 	if req.Uuid != "" { | ||||
| 		valueService, existErr := dao.GetValueAddServiceUuidsByBundleUuid(req.Uuid) | ||||
| 		if existErr != nil { | ||||
| 			return res, existErr | ||||
| 		} | ||||
| 		if valueService != nil && len(valueService) > 0 { | ||||
| 			for _, v := range valueService { | ||||
| 				existValueService[v] = v | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	var cancelValueAddService = make(map[string]string) | ||||
| 	selectService := make([]*model.BundleToValueAddService, 0) | ||||
| 	if req.Language == msg.ZH_CN && req.SelectValueAddService != nil && len(req.SelectValueAddService) > 0 { | ||||
| 		for _, v := range req.SelectValueAddService { | ||||
| 			detail, checkErr := dao.ValueAddServiceDetailByUuidAndLanguage(v.ValueAddUuid, req.Language) | ||||
| 			if checkErr != nil { | ||||
| 				if checkErr == gorm.ErrRecordNotFound { | ||||
| 					return res, errors.New(fmt.Sprintf("所选增值服务[%s]%s版不存在,请先创建对应增值套餐", v.ServiceName, req.Language)) | ||||
| 				} else { | ||||
| 					return res, checkErr | ||||
| 				} | ||||
| 			} | ||||
| 			if detail.PriceType != req.PriceType { | ||||
| 				if req.Uuid == "" { | ||||
| 					//中文套餐创建时,币种不一致直接返回错误
 | ||||
| 					return res, errors.New(fmt.Sprintf("所选增值服务[%s]%s币种与套餐币种不一致", detail.ServiceName, req.Language)) | ||||
| 				} else { | ||||
| 					//更新时,判断是否已存在,存在则取消关联
 | ||||
| 					_, ok := existValueService[v.ValueAddUuid] | ||||
| 					if ok { | ||||
| 						cancelValueAddService[v.ValueAddUuid] = detail.ServiceName | ||||
| 						continue | ||||
| 					} else { | ||||
| 						//币种不一致,新加币种时返回错误
 | ||||
| 						return res, errors.New(fmt.Sprintf("所选增值服务[%s]%s币种与套餐币种不一致", detail.ServiceName, req.Language)) | ||||
| 
 | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			selectService = append(selectService, &model.BundleToValueAddService{ | ||||
| 				ValueUid:  v.ValueAddUuid, | ||||
| 				IsDisplay: v.IsDisplay, | ||||
| 			}) | ||||
| 		} | ||||
| 	} | ||||
| 	tx := app.ModuleClients.BundleDB.Begin() | ||||
| 	defer func() { | ||||
| 		if err != nil { | ||||
| 			tx.Rollback() | ||||
| 		} else { | ||||
| 			tx.Commit() | ||||
| 		} | ||||
| 	}() | ||||
| 	_, err = dao.BundleDetailByUuidAndLanguage(req.Uuid, req.Language) | ||||
| 	if err != nil { | ||||
| 		if err == gorm.ErrRecordNotFound { | ||||
| 			if req.Language != msg.ZH_CN { | ||||
| 				_, err = dao.BundleDetailByUuidAndLanguage(req.Uuid, msg.ZH_CN) | ||||
| 				if err != nil { | ||||
| 					if err == gorm.ErrRecordNotFound { | ||||
| 						res.Msg = "请先创建中文版本套餐" | ||||
| 						return res, errors.New("请先创建中文版本套餐") | ||||
| 					} else { | ||||
| 						return res, err | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			if req.Language == msg.ZH_CN { | ||||
| 				bundleProfile.UUID = utils.GetUUID() | ||||
| 				if err = dao.TxCreateBundle(tx, bundleProfile); err != nil { | ||||
| 					return res, errors.New("保存中文语言套餐失败: " + err.Error()) | ||||
| 				} | ||||
| 				bundleLang.UUID = bundleProfile.UUID | ||||
| 				res.Uuid = bundleProfile.UUID | ||||
| 				// 新建套餐时插入中间表
 | ||||
| 				for _, s := range selectService { | ||||
| 					s.BundleUuid = bundleProfile.UUID | ||||
| 				} | ||||
| 				if len(selectService) > 0 { | ||||
| 					if err = dao.CreateBundleToValueAddService(tx, selectService); err != nil { | ||||
| 						return res, errors.New("保存套餐与增值服务关联失败: " + err.Error()) | ||||
| 					} | ||||
| 				} | ||||
| 			} else { | ||||
| 				bundleLang.UUID = req.Uuid | ||||
| 				res.Uuid = req.Uuid | ||||
| 				valueUuid, err1 := dao.GetValueAddServiceUuidsByBundleUuid(bundleLang.UUID) | ||||
| 				if err1 != nil { | ||||
| 					return res, err1 | ||||
| 				} | ||||
| 				count := 0 | ||||
| 				if valueUuid != nil && len(valueUuid) > 0 { | ||||
| 					for _, v := range valueUuid { | ||||
| 						//可以改成批量获取
 | ||||
| 						valueDetail, err2 := dao.ValueAddServiceDetailByUuidAndLanguage(v, req.Language) | ||||
| 						if err2 != nil { | ||||
| 							return res, err2 | ||||
| 						} | ||||
| 						if valueDetail.PriceType != req.PriceType { | ||||
| 							if err = tx.Where("bundle_uuid =? AND value_uid =?", bundleLang.UUID, v).Delete(&model.BundleToValueAddService{}).Error; err != nil { | ||||
| 								return res, errors.New("删除套餐与增值服务关联失败: " + err.Error()) | ||||
| 							} | ||||
| 							count++ | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 				res.CancelNum = int64(count) | ||||
| 			} | ||||
| 			if err = dao.TxCreateBundleLang(tx, bundleLang); err != nil { | ||||
| 				return res, errors.New("保存语言套餐失败: " + err.Error()) | ||||
| 			} | ||||
| 			res.Msg = "保存成功" | ||||
| 			return res, nil | ||||
| 		} else { | ||||
| 			return | ||||
| 		} | ||||
| 	} else { // 已存在,进行更新
 | ||||
| 
 | ||||
| 		// 更新前保存历史记录
 | ||||
| 		// if err = dao.CreateBundleProfileHistory(tx,req.Uuid); err != nil {
 | ||||
| 		// 	return res, errors.New("保存套餐历史记录失败: " + err.Error())
 | ||||
| 		// }
 | ||||
| 
 | ||||
| 		if req.Language == msg.ZH_CN { | ||||
| 			if len(cancelValueAddService) > 0 { | ||||
| 				cancel := "以下增值服务:" | ||||
| 				for _, v := range cancelValueAddService { | ||||
| 					cancel += fmt.Sprintf("[%s]%s", v, req.Language) | ||||
| 					if err = tx.Where("bundle_uuid = ? AND value_uid = ?", req.Uuid, v).Delete(&model.BundleToValueAddService{}).Error; err != nil { | ||||
| 						return res, errors.New("删除套餐与增值服务关联失败: " + err.Error()) | ||||
| 					} | ||||
| 				} | ||||
| 				cancel += "版币种与套餐币种不一致" | ||||
| 				res.Msg = "保存cn成功 " + cancel | ||||
| 			} | ||||
| 			res.CancelNum = int64(len(cancelValueAddService)) | ||||
| 			updateBundle := map[string]interface{}{ | ||||
| 				"name":       req.Name, | ||||
| 				"sort":       req.Sort, | ||||
| 				"content":    req.Content, | ||||
| 				"price":      req.Price, | ||||
| 				"price_type": req.PriceType, | ||||
| 				"bg_img1":    req.BgImg1, | ||||
| 				"bg_img2":    req.BgImg2, | ||||
| 			} | ||||
| 			if err = dao.TxUpdateBundle(tx, req.Uuid, updateBundle); err != nil { | ||||
| 				return res, err | ||||
| 			} | ||||
| 			// 更新中间表函数
 | ||||
| 			if err = diffUpdateBundleToValueAddService(tx, req.Uuid, selectService); err != nil { | ||||
| 				tx.Rollback() | ||||
| 				return res, err | ||||
| 			} | ||||
| 		} else { | ||||
| 			//更新其他语言时 先获取所有关联增值服务,判断币种是否一致,不一致则取消关联
 | ||||
| 			valueAddService, err := dao.GetBundleToValueAddServiceByBundleUuid(req.Uuid) | ||||
| 			if err != nil { | ||||
| 				return res, err | ||||
| 			} | ||||
| 			cancelValueService := make(map[string]string) | ||||
| 			for _, v := range valueAddService { | ||||
| 				detail, checkErr := dao.ValueAddServiceDetailByUuidAndLanguage(v.ValueUid, req.Language) | ||||
| 				if checkErr != nil { | ||||
| 					if checkErr == gorm.ErrRecordNotFound { | ||||
| 						continue | ||||
| 					} else { | ||||
| 						return res, checkErr | ||||
| 					} | ||||
| 				} | ||||
| 				if detail.PriceType != req.PriceType { | ||||
| 					cancelValueService[v.ValueUid] = detail.ServiceName | ||||
| 					continue | ||||
| 				} | ||||
| 			} | ||||
| 			if int64(len(cancelValueService)) > 0 { | ||||
| 				cancel := "以下增值服务:" | ||||
| 				for k, v := range cancelValueService { | ||||
| 					cancel += fmt.Sprintf("[%s]%s", v, req.Language) | ||||
| 					if err = tx.Where("bundle_uuid = ? AND value_uid = ?", req.Uuid, k).Delete(&model.BundleToValueAddService{}).Error; err != nil { | ||||
| 						return res, errors.New("删除套餐与增值服务关联失败: " + err.Error()) | ||||
| 					} | ||||
| 				} | ||||
| 				cancel += "版币种与套餐币种不一致,已取消相关关联" | ||||
| 				res.Msg = "保存成功 " + cancel | ||||
| 				res.CancelNum = int64(len(cancelValueService)) | ||||
| 			} | ||||
| 		} | ||||
| 		updateBundleLang := map[string]interface{}{ | ||||
| 			"name":       req.Name, | ||||
| 			"content":    req.Content, | ||||
| 			"price":      req.Price, | ||||
| 			"price_type": req.PriceType, | ||||
| 		} | ||||
| 		if err = dao.TxUpdateBundleLang(tx, req.Uuid, req.Language, updateBundleLang); err != nil { | ||||
| 			return res, err | ||||
| 		} | ||||
| 
 | ||||
| 		res.Uuid = req.Uuid | ||||
| 		if res.Msg == "" { | ||||
| 			res.Msg = "保存成功" | ||||
| 		} | ||||
| 	} | ||||
| 	return res, nil | ||||
| } | ||||
| 
 | ||||
| func BundleListV2(req *bundle.BundleListRequest) (res *bundle.BundleListResponse, err error) { | ||||
| 	res = new(bundle.BundleListResponse) | ||||
| 	res, err = dao.BundleListV2(req) | ||||
| 	return | ||||
| } | ||||
| func BundleDetailV2(req *bundle.BundleDetailRequest) (res *bundle.BundleDetailResponseV2, err error) { | ||||
| 	res = new(bundle.BundleDetailResponseV2) | ||||
| 	if req.Uuid == "" { | ||||
| 		res.Msg = "" | ||||
| 		return res, errors.New("uuid不能为空") | ||||
| 	} | ||||
| 	if req.Language == "" { | ||||
| 		res.Msg = "" | ||||
| 		return res, errors.New("language不能为空") | ||||
| 	} | ||||
| 	res, err = dao.BundleDetailV2(req) | ||||
| 	if err != nil { | ||||
| 		res.Msg = err.Error() | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
| 
 | ||||
| func HandShelf(req *bundle.HandShelfRequest) (res *bundle.CommonResponse, err error) { | ||||
| 	res = new(bundle.CommonResponse) | ||||
| 	if req.ShelfStatus != 1 && req.ShelfStatus != 2 { | ||||
| 		res.Msg = "" | ||||
| 		return res, errors.New("无效的上下架状态") | ||||
| 	} | ||||
| 	res, err = dao.HandShelf(req.Uuid, req.ShelfStatus) | ||||
| 	return | ||||
| } | ||||
| 
 | ||||
| // 差异更新套餐与增值服务中间表
 | ||||
| func diffUpdateBundleToValueAddService(tx *gorm.DB, bundleUuid string, selectService []*model.BundleToValueAddService) error { | ||||
| 	oldUuids, err := dao.GetValueAddServiceUuidsByBundleUuid(bundleUuid) | ||||
| 	if err != nil { | ||||
| 		return errors.New("查询旧套餐与增值服务关联失败: " + err.Error()) | ||||
| 	} | ||||
| 	newUuids := make(map[string]*model.BundleToValueAddService) | ||||
| 	for _, s := range selectService { | ||||
| 		newUuids[s.ValueUid] = s | ||||
| 	} | ||||
| 	oldSet := make(map[string]struct{}) | ||||
| 	for _, uid := range oldUuids { | ||||
| 		oldSet[uid] = struct{}{} | ||||
| 	} | ||||
| 	// 需要新增的
 | ||||
| 	toAdd := make([]*model.BundleToValueAddService, 0) | ||||
| 	for uid, s := range newUuids { | ||||
| 		if _, exist := oldSet[uid]; !exist { | ||||
| 			s.BundleUuid = bundleUuid | ||||
| 			toAdd = append(toAdd, s) | ||||
| 		} | ||||
| 	} | ||||
| 	// 需要删除的
 | ||||
| 	toDel := make([]string, 0) | ||||
| 	for _, uid := range oldUuids { | ||||
| 		if _, exist := newUuids[uid]; !exist { | ||||
| 			toDel = append(toDel, uid) | ||||
| 		} | ||||
| 	} | ||||
| 	if len(toDel) > 0 { | ||||
| 		if err = tx.Where("bundle_uuid = ? AND value_uid IN ?", bundleUuid, toDel).Delete(&model.BundleToValueAddService{}).Error; err != nil { | ||||
| 			return errors.New("删除套餐与增值服务关联失败: " + err.Error()) | ||||
| 		} | ||||
| 	} | ||||
| 	if len(toAdd) > 0 { | ||||
| 		if err = dao.CreateBundleToValueAddService(tx, toAdd); err != nil { | ||||
| 			return errors.New("保存套餐与增值服务关联失败: " + err.Error()) | ||||
| 		} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| @ -1,12 +1,18 @@ | ||||
| package logic | ||||
| 
 | ||||
| import ( | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"micro-bundle/internal/dao" | ||||
| 	"micro-bundle/internal/model" | ||||
| 	"micro-bundle/pb/bundle" | ||||
| 	"micro-bundle/pkg/app" | ||||
| 	"micro-bundle/pkg/msg" | ||||
| 	"strconv" | ||||
| 	"time" | ||||
| 
 | ||||
| 	"github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils" | ||||
| 	"gorm.io/gorm" | ||||
| ) | ||||
| 
 | ||||
| // 增值套餐创建
 | ||||
| @ -131,3 +137,247 @@ func ValueAddBundleDetail(req *bundle.ValueAddBundleDetailRequest) (res *bundle. | ||||
| 	res.Msg = "SUCCESS" | ||||
| 	return | ||||
| } | ||||
| 
 | ||||
| //*******************************************************************新增值服务***********************
 | ||||
| 
 | ||||
| // 增值套餐保存(无则新增,有则更新)
 | ||||
| func SaveValueAddService(in *bundle.ValueAddServiceLang) (res *bundle.SaveResponse, err error) { | ||||
| 	res = &bundle.SaveResponse{} | ||||
| 	if in.Language == "" { | ||||
| 		return res, errors.New("语言参数不能为空") | ||||
| 	} | ||||
| 	var options model.PriceOptions | ||||
| 	for _, option := range in.Options { | ||||
| 		price, parseErr := strconv.ParseFloat(option.Price, 32) | ||||
| 		if parseErr != nil { | ||||
| 			return res, parseErr | ||||
| 		} | ||||
| 		options = append(options, &model.PriceOption{ | ||||
| 			Id:     int32(option.Id), | ||||
| 			Num:    option.Num, | ||||
| 			Symbol: option.Symbol, | ||||
| 			Price:  float32(price), | ||||
| 		}) | ||||
| 	} | ||||
| 	ok, err := model.ValidateOptions(options) | ||||
| 	if !ok { | ||||
| 		return res, err | ||||
| 	} | ||||
| 	valueAddService := &model.ValueAddService{ | ||||
| 		ServiceName: in.ServiceName, | ||||
| 		ServiceType: in.ServiceType, | ||||
| 	} | ||||
| 	originalPrice, err := strconv.ParseFloat(in.OriginalPrice, 32) | ||||
| 	if err != nil { | ||||
| 		return res, err | ||||
| 	} | ||||
| 	valueAddServiceLang := &model.ValueAddServiceLang{ | ||||
| 		ServiceName:   in.ServiceName, | ||||
| 		ServiceType:   in.ServiceType, | ||||
| 		PriceMode:     int32(in.PriceMode), | ||||
| 		OriginalPrice: float32(originalPrice), | ||||
| 		Unit:          in.Unit, | ||||
| 		Language:      in.Language, | ||||
| 		PriceType:     in.PriceType, | ||||
| 		Options:       options, | ||||
| 	} | ||||
| 	if in.Uuid == "" && in.Language != msg.ZH_CN { | ||||
| 		return res, errors.New("请先新增简体中文套餐,再添加其他语言版本") | ||||
| 	} | ||||
| 	tx := app.ModuleClients.BundleDB.Begin() | ||||
| 	defer func() { | ||||
| 		if err != nil { | ||||
| 			tx.Rollback() | ||||
| 		} else { | ||||
| 			tx.Commit() | ||||
| 		} | ||||
| 	}() | ||||
| 	// 检查当前语言套餐是否存在
 | ||||
| 	_, err = dao.ValueAddServiceDetailByUuidAndLanguage(in.Uuid, in.Language) | ||||
| 	if err != nil { | ||||
| 		if err == gorm.ErrRecordNotFound { // 当前语言套餐不存在
 | ||||
| 			if in.Language != msg.ZH_CN { | ||||
| 				_, err = dao.ValueAddServiceDetailByUuidAndLanguage(in.Uuid, msg.ZH_CN) | ||||
| 				if err != nil { | ||||
| 					if err != gorm.ErrRecordNotFound { | ||||
| 						return res, errors.New("请先创建中文套餐") | ||||
| 					} else { | ||||
| 						// // 新语言补充:只要UUID存在即可直接插入新语言
 | ||||
| 						// if in.Uuid != "" {
 | ||||
| 						// 	valueAddServiceLang.UUID = in.Uuid
 | ||||
| 						// 	if err = dao.CreateValueAddServiceLang(tx, valueAddServiceLang); err != nil {
 | ||||
| 						// 		return res, errors.New("补充新语言套餐失败: " + err.Error())
 | ||||
| 						// 	}
 | ||||
| 						// 	res.Uuid = in.Uuid
 | ||||
| 						// 	res.Msg = "补充新语言套餐成功"
 | ||||
| 						// 	return
 | ||||
| 						// }
 | ||||
| 						return | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			if in.Language == msg.ZH_CN { | ||||
| 				valueAddService.UUID = utils.GetUUID() | ||||
| 				err = dao.CreateValueAddService(tx, valueAddService) | ||||
| 				if err != nil { | ||||
| 					return res, errors.New("保存中文语言套餐失败: " + err.Error()) | ||||
| 				} | ||||
| 				valueAddServiceLang.UUID = valueAddService.UUID | ||||
| 				res.Uuid = valueAddService.UUID | ||||
| 				if err = dao.CreateValueAddServiceLang(tx, valueAddServiceLang); err != nil { | ||||
| 					return res, errors.New("保存语言套餐失败: " + err.Error()) | ||||
| 				} | ||||
| 			} | ||||
| 			langList := []string{msg.ZH_TW, msg.EN, msg.DE_DE, msg.JS_JP} | ||||
| 			for _, lang := range langList { | ||||
| 				otherLang := *valueAddServiceLang | ||||
| 				otherLang.Language = lang | ||||
| 				if err = dao.CreateValueAddServiceLang(tx, &otherLang); err != nil { | ||||
| 					return res, errors.New(fmt.Sprintf("保存%s语言套餐失败: ", lang) + err.Error()) | ||||
| 				} | ||||
| 			} | ||||
| 			res.Msg = "保存成功" | ||||
| 			return | ||||
| 		} else { | ||||
| 			return | ||||
| 		} | ||||
| 	} else { | ||||
| 		// 已存在,进行更新
 | ||||
| 		//中文状态下,更新主表和语言表
 | ||||
| 		if in.Language == msg.ZH_CN { | ||||
| 			updateService := map[string]interface{}{ | ||||
| 				"uuid":         in.Uuid, | ||||
| 				"service_name": in.ServiceName, | ||||
| 				"service_type": in.ServiceType, | ||||
| 			} | ||||
| 			if err = dao.UpdateValueAddService(tx, updateService); err != nil { | ||||
| 				return res, err | ||||
| 			} | ||||
| 		} | ||||
| 		// 查找所有与该增值服务关联的套餐,若币种不一致则取消关联并统计
 | ||||
| 		var cancelNum int64 = 0 | ||||
| 		bundleToValueAddList, _ := dao.GetBundleToValueAddServiceByValueUid(in.Uuid) | ||||
| 		for _, rel := range bundleToValueAddList { | ||||
| 			bundleProfile, _ := dao.BundleDetailByUuidAndLanguage(rel.BundleUuid, in.Language) | ||||
| 			if bundleProfile != nil && bundleProfile.PriceType != in.PriceType { | ||||
| 				dao.DeleteBundleToValueAddService(tx, rel.BundleUuid, in.Uuid) | ||||
| 				cancelNum++ | ||||
| 			} | ||||
| 		} | ||||
| 		//更新语言表
 | ||||
| 		updateLangService := map[string]interface{}{ | ||||
| 			"uuid":           in.Uuid, | ||||
| 			"service_name":   in.ServiceName, | ||||
| 			"service_type":   in.ServiceType, | ||||
| 			"price_mode":     in.PriceMode, | ||||
| 			"original_price": in.OriginalPrice, | ||||
| 			"unit":           in.Unit, | ||||
| 			"price_type":     in.PriceType, | ||||
| 			"options":        options, | ||||
| 			"language":       in.Language, | ||||
| 		} | ||||
| 		if err = dao.UpdateValueAddServiceLang(tx, updateLangService); err != nil { | ||||
| 			return res, err | ||||
| 		} | ||||
| 		res.Uuid = in.Uuid | ||||
| 		res.Msg = "保存成功" | ||||
| 		res.CancelNum = cancelNum | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
| 
 | ||||
| // 增值套餐列表
 | ||||
| func ValueAddServiceList(req *bundle.ValueAddServiceListRequest) (res *bundle.ValueAddServiceListResponse, err error) { | ||||
| 	res = &bundle.ValueAddServiceListResponse{} | ||||
| 	list, total, err := dao.ValueAddServiceList(req) | ||||
| 	if err != nil { | ||||
| 		res.Msg = msg.ErrorValueAddServiceList | ||||
| 		return res, err | ||||
| 	} | ||||
| 	for _, valueAddService := range list { | ||||
| 		serviceInfo := &bundle.ValueAddService{ | ||||
| 			Uuid:        valueAddService.UUID, | ||||
| 			ServiceName: valueAddService.ServiceName, | ||||
| 			ServiceType: valueAddService.ServiceType, | ||||
| 		} | ||||
| 		for _, serviceLang := range valueAddService.ValueAddServiceLang { | ||||
| 			serviceLangInfo := &bundle.ValueAddServiceLang{ | ||||
| 				Uuid:          valueAddService.UUID, | ||||
| 				ServiceName:   serviceLang.ServiceName, | ||||
| 				ServiceType:   serviceLang.ServiceType, | ||||
| 				PriceMode:     serviceLang.PriceMode, | ||||
| 				OriginalPrice: fmt.Sprintf("%.2f", serviceLang.OriginalPrice), | ||||
| 				Unit:          serviceLang.Unit, | ||||
| 				PriceType:     int64(serviceLang.PriceType), | ||||
| 				Language:      serviceLang.Language, | ||||
| 				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"), | ||||
| 			} | ||||
| 			if serviceLang.Options != nil && len(serviceLang.Options) > 0 { | ||||
| 				var options []*bundle.ValueAddPriceOptions | ||||
| 				for _, option := range serviceLang.Options { | ||||
| 					options = append(options, &bundle.ValueAddPriceOptions{ | ||||
| 						Id:     int64(option.Id), | ||||
| 						Num:    option.Num, | ||||
| 						Symbol: option.Symbol, | ||||
| 						Price:  fmt.Sprintf("%.2f", option.Price), | ||||
| 					}) | ||||
| 				} | ||||
| 				serviceLangInfo.Options = options | ||||
| 			} | ||||
| 			serviceInfo.ServiceLang = append(serviceInfo.ServiceLang, serviceLangInfo) | ||||
| 		} | ||||
| 		res.ValueAddServiceList = append(res.ValueAddServiceList, serviceInfo) | ||||
| 	} | ||||
| 	res.Total = int32(total) | ||||
| 	res.Msg = msg.SuccessValueAddServiceList | ||||
| 	return | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| // 增值套餐详情
 | ||||
| func ValueAddServiceDetail(req *bundle.ValueAddServiceDetailRequest) (res *bundle.ValueAddServiceDetailResponse, err error) { | ||||
| 	res = &bundle.ValueAddServiceDetailResponse{} | ||||
| 	if req.Uuid == "" { | ||||
| 		res.Msg = msg.ErrorValueAddServiceInfo | ||||
| 		return res, errors.New("uuid不能为空") | ||||
| 	} | ||||
| 	if req.Language == "" { | ||||
| 		res.Msg = msg.ErrorValueAddServiceInfo | ||||
| 		return res, errors.New("语言选项不能为空") | ||||
| 	} | ||||
| 	detail, err := dao.ValueAddServiceDetailByUuidAndLanguage(req.Uuid, req.Language) | ||||
| 	if err != nil { | ||||
| 		res.Msg = msg.ErrorValueAddServiceInfo | ||||
| 		return res, err | ||||
| 	} | ||||
| 	langOptions := []*bundle.ValueAddPriceOptions{} | ||||
| 	if detail.Options != nil && len(detail.Options) > 0 { | ||||
| 		for _, opt := range detail.Options { | ||||
| 			langOptions = append(langOptions, &bundle.ValueAddPriceOptions{ | ||||
| 				Id:     int64(opt.Id), | ||||
| 				Num:    opt.Num, | ||||
| 				Symbol: opt.Symbol, | ||||
| 				Price:  fmt.Sprintf("%.2f", opt.Price), | ||||
| 			}) | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	serviceLang := &bundle.ValueAddServiceLang{ | ||||
| 		Uuid:          detail.UUID, | ||||
| 		ServiceName:   detail.ServiceName, | ||||
| 		ServiceType:   detail.ServiceType, | ||||
| 		Language:      detail.Language, | ||||
| 		PriceMode:     detail.PriceMode, | ||||
| 		OriginalPrice: fmt.Sprintf("%.2f", detail.OriginalPrice), | ||||
| 		Unit:          detail.Unit, | ||||
| 		PriceType:     int64(detail.PriceType), | ||||
| 		Options:       langOptions, | ||||
| 		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"), | ||||
| 	} | ||||
| 
 | ||||
| 	res.ValueAddServiceLang = serviceLang | ||||
| 	res.Msg = msg.SuccessValueAddServiceInfo | ||||
| 	return | ||||
| } | ||||
|  | ||||
| @ -1,18 +1,73 @@ | ||||
| package model | ||||
| 
 | ||||
| import "gorm.io/gorm" | ||||
| import ( | ||||
| 	"gorm.io/gorm" | ||||
| 	"gorm.io/plugin/soft_delete" | ||||
| ) | ||||
| 
 | ||||
| type BundleProfile struct { | ||||
| 	gorm.Model | ||||
| 	UUID             string  `json:"uuid" gorm:"column:uuid;type:varchar(1024);comment:套餐UUID"` | ||||
| 	Name             string  `json:"name" gorm:"column:name;type:varchar(2048);comment:套餐名称"` | ||||
| 	Price            float32 `json:"price" gorm:"column:price;type:decimal(12,2);comment:套餐价格"` | ||||
| 	PriceType int64   `json:"priceType" gorm:"column:price_type;type:int;comment:套餐价格类型 1:人民币 2:美元"` | ||||
| 	PriceType        int64   `json:"priceType" gorm:"column:price_type;type:int;comment:套餐类型 1:人民币 2:美元"` | ||||
| 	Contract         string  `json:"contract" gorm:"type:varchar(1024);comment:合同"` | ||||
| 	// 合同有效时长
 | ||||
| 	ContractDuration int     `json:"contractDuration" gorm:"column:contract_duration;type:int;comment:合同有效时长"` | ||||
| 	Content          string  `json:"content" gorm:"column:content;type:text;comment:套餐内容"` | ||||
| 	CompanySign      string  `json:"companySign" gorm:"column:company_sign;type:varchar(1024);comment:公司签名"` | ||||
| 	Language         string  `json:"language" gorm:"column:language;type:varchar(32);comment:套餐语言 zh-CN EN"` | ||||
| 	BundleCommonUid  string  `json:"bundleCommonUid" gorm:"column:bundle_common_uid;type:varchar(1024);comment:套餐公共ID"` | ||||
| 
 | ||||
| 	Sort                    int64                     `json:"sort" gorm:"column:sort;type:int;comment:套餐排序"` //数字越小越靠前,同大小后创建优先
 | ||||
| 	ShelfStatus             int64                     `json:"shelfStatus" gorm:"column:shelf_status;type:int;default:2;comment:上架状态  1:上架 2:下架"` | ||||
| 	BgImg1                  string                    `json:"bgImg1" gorm:"column:bg_img1;type:varchar(1024);comment:背景图-首页"` | ||||
| 	BgImg2                  string                    `json:"bgImg2" gorm:"column:bg_img2;type:varchar(1024);comment:背景图-我的"` | ||||
| 	BundleToValueAddService []BundleToValueAddService `gorm:"foreignKey:BundleUuid;references:UUID" json:"bundleToValueAddService"` | ||||
| 	BundleProfileLang       []BundleProfileLang       `gorm:"foreignKey:UUID;references:UUID" json:"bundleProfileLang"` | ||||
| } | ||||
| type BundleProfileLang struct { | ||||
| 	Id        int32   `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT" json:"id"` | ||||
| 	UUID      string  `json:"uuid" gorm:"column:uuid;type:varchar(1024);comment:套餐UUID"` | ||||
| 	Name      string  `json:"name" gorm:"column:name;type:varchar(2048);comment:套餐名称"` | ||||
| 	Price     float32 `json:"price" gorm:"column:price;type:decimal(12,2);comment:套餐价格"` | ||||
| 	PriceType int64   `json:"priceType" gorm:"column:price_type;type:int;comment:套餐类型 1:人民币 2:美元"` | ||||
| 	Content   string  `json:"content" gorm:"column:content;type:text;comment:套餐内容"` | ||||
| 	Language  string  `json:"language" gorm:"column:language;type:varchar(32);comment:套餐语言 zh-CN zh-TW EN de-DE js-JP(中繁英德日)"` | ||||
| 	CreatedAt int64   `gorm:"column:created_at;autoCreateTime"` | ||||
| 	UpdatedAt int64   `gorm:"column:updated_at;autoCreateTime"` | ||||
| 	DeletedAt soft_delete.DeletedAt | ||||
| } | ||||
| type BundleToValueAddService struct { | ||||
| 	Id              int32           `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT" json:"id"` | ||||
| 	BundleUuid      string          `json:"bundleUuid" gorm:"column:bundle_uuid;type:varchar(1024);comment:套餐UUID"` | ||||
| 	BundleProfile   BundleProfile   `gorm:"foreignKey:BundleUuid;references:UUID" json:"bundleProfile"` | ||||
| 	ValueUid        string          `json:"valueUid" gorm:"column:value_uid;type:varchar(1024);comment:增值服务UUID"` | ||||
| 	ValueAddService ValueAddService `gorm:"foreignKey:ValueUid;references:UUID" json:"valueAddService"` | ||||
| 	IsDisplay       bool            `json:"isDisplay" gorm:"column:is_display;type:tinyint(1);comment:是否显示"` | ||||
| 	CreatedAt       int64           `gorm:"column:created_at;autoCreateTime"` | ||||
| 	UpdatedAt       int64           `gorm:"column:updated_at;autoCreateTime"` | ||||
| 	DeletedAt       soft_delete.DeletedAt | ||||
| } | ||||
| 
 | ||||
| // todo套餐修改历史
 | ||||
| type BundleProfileHistory struct { | ||||
| 	Id            int32         `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT" json:"id"` | ||||
| 	Uuid          string        `json:"uuid" gorm:"column:uuid;type:varchar(1024);comment:UUID"` | ||||
| 	BundleProfile BundleProfile `gorm:"foreignKey:Uuid;references:UUID" json:"bundleProfile"` | ||||
| 	CreatedAt     int64         `gorm:"column:created_at;autoCreateTime"` | ||||
| 	UpdatedAt     int64         `gorm:"column:updated_at;autoCreateTime"` | ||||
| 	DeletedAt     soft_delete.DeletedAt | ||||
| } | ||||
| 
 | ||||
| func (m *BundleProfile) TableName() string { | ||||
| 	return "bundle_profile" | ||||
| } | ||||
| func (m *BundleProfileLang) TableName() string { | ||||
| 	return "bundle_profile_lang" | ||||
| } | ||||
| func (m *BundleToValueAddService) TableName() string { | ||||
| 	return "bundle_to_value_add_service" | ||||
| } | ||||
| func (m *BundleProfileHistory) TableName() string { | ||||
| 	return "bundle_profile_history" | ||||
| } | ||||
|  | ||||
| @ -33,6 +33,8 @@ type BundleOrderRecords struct { | ||||
| 	BundleCommonUid       string  `json:"bundleCommonUid" gorm:"column:bundle_common_uid;type:text;comment:套餐公共ID"` | ||||
| 	AddBundleCommonUid    string  `json:"addBundleCommonUid" gorm:"column:add_bundle_common_uid;type:text;comment:附加套餐公共ID"` | ||||
| 	FinancialConfirmation int32   `json:"financialConfirmation" gorm:"column:financial_confirmation;type:int;comment:财务确认 1:未确认 2:已确认"` | ||||
| 	ExpirationTime        string  `json:"expirationTime" gorm:"column:expiration_time;comment:套餐过期时间"` | ||||
| 	BundleCommonJson      string  `json:"bundle_common_json" gorm:"column:bundle_common_json;type:json;serializer:json;comment:套餐信息"` | ||||
| } | ||||
| 
 | ||||
| // 财务确认状态
 | ||||
|  | ||||
| @ -1,6 +1,10 @@ | ||||
| package model | ||||
| 
 | ||||
| import ( | ||||
| 	"database/sql/driver" | ||||
| 	"encoding/json" | ||||
| 	"errors" | ||||
| 
 | ||||
| 	"gorm.io/plugin/soft_delete" | ||||
| ) | ||||
| 
 | ||||
| @ -24,16 +28,105 @@ type ValueAddBundleProfile struct { | ||||
| 	DeletedAt          soft_delete.DeletedAt | ||||
| } | ||||
| 
 | ||||
| //func (ValueAddBundleProfile) TableName() string {
 | ||||
| //	return "value_add_bundle_profile2"
 | ||||
| //}
 | ||||
| // 新增值套餐主表
 | ||||
| type ValueAddService struct { | ||||
| 	Id                      int32                     `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT" json:"id"` | ||||
| 	UUID                    string                    `json:"uuid" gorm:"column:uuid;type:varchar(1024);comment:增值套餐UUID"` | ||||
| 	ServiceName             string                    `json:"serviceName" gorm:"column:service_name;type:varchar(1024);comment:增值服务名称"` | ||||
| 	ServiceType             int32                     `json:"serviceType" gorm:"column:service_type;type:int;comment:服务类型 1:视频 2:图文 3:数据报表 4:账号数 5:可用时长"` | ||||
| 	ValueAddServiceLang     []ValueAddServiceLang     `gorm:"foreignKey:UUID;references:UUID"` | ||||
| 	BundleToValueAddService []BundleToValueAddService `gorm:"foreignKey:ValueUid;references:UUID"` | ||||
| 	CreatedAt               int64                     `gorm:"column:created_at;autoCreateTime"` | ||||
| 	UpdatedAt               int64                     `gorm:"column:updated_at;autoCreateTime"` | ||||
| 	DeletedAt               soft_delete.DeletedAt | ||||
| } | ||||
| 
 | ||||
| //type ValueAddBundleRecord struct {
 | ||||
| //	gorm.Model
 | ||||
| //	UUID              string  `json:"uuid" gorm:"column:uuid;type:varchar(1024);comment:增值套餐UUID"`
 | ||||
| //	OriginalPrice     float32 `json:"originalPrice" gorm:"column:original_price;type:decimal(12,2);comment:原单价"`
 | ||||
| //	ValueAddBundleNum int     `json:"valueAddBundleNum" gorm:"column:value_add_bundle_num;type:int;comment:增值套餐数量"`
 | ||||
| //	DiscountPrice     float32 `json:"discountPrice" gorm:"column:discount_price;type:decimal(12,2);comment:优惠单价"`
 | ||||
| //	SavedAmount       float32 `json:"savedAmount" gorm:"column:saved_amount;type:decimal(12,2);comment:节省金额"`
 | ||||
| //	TotalPrice        float32 `json:"totalPrice" gorm:"column:total_price;type:decimal(12,2);comment:增值套餐总价"`
 | ||||
| //}
 | ||||
| // 新增值套餐语言表
 | ||||
| type ValueAddServiceLang struct { | ||||
| 	Id            int32        `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT" json:"id"` | ||||
| 	UUID          string       `json:"uuid" gorm:"column:uuid;type:varchar(1024);comment:增值套餐UUID"` | ||||
| 	ServiceName   string       `json:"serviceName" gorm:"column:service_name;type:varchar(1024);comment:增值服务名称"` | ||||
| 	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:总价"` | ||||
| 	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:增值服务总价"` | ||||
| 	Unit          string       `json:"unit" gorm:"column:unit;type:varchar(50);comment:单位 1:个 2:条 3:天 4:月 5:年"` | ||||
| 	Language      string       `json:"language" gorm:"column:language;type:varchar(32);comment:套餐语言 zh-CN zh-TW EN de-DE js-JP(中繁英德日)"` | ||||
| 	PriceType     int64        `json:"priceType" gorm:"column:price_type;type:int;comment:币种 1:人民币 2:美元 3:日元 4:欧元"` | ||||
| 	Options       PriceOptions `gorm:"column:options;type:json" json:"options"` | ||||
| 	CreatedAt     int64        `gorm:"column:created_at;autoCreateTime"` | ||||
| 	UpdatedAt     int64        `gorm:"column:updated_at;autoCreateTime"` | ||||
| 	DeletedAt     soft_delete.DeletedAt | ||||
| } | ||||
| type PriceOptions []*PriceOption | ||||
| type PriceOption struct { | ||||
| 	Id     int32   `json:"id"` | ||||
| 	Num    int32   `json:"num"` | ||||
| 	Symbol string  `json:"symbol"` // 符号> < = <= =>
 | ||||
| 	Price  float32 `json:"price"`  // 价格(根据priceMode决定是单价还是总价)
 | ||||
| } | ||||
| 
 | ||||
| // 实现 driver.Valuer 接口
 | ||||
| func (o PriceOptions) Value() (driver.Value, error) { | ||||
| 	return json.Marshal(o) | ||||
| } | ||||
| 
 | ||||
| // 实现 sql.Scanner 接口
 | ||||
| func (o *PriceOptions) Scan(value interface{}) error { | ||||
| 	bytes, ok := value.([]byte) | ||||
| 	if !ok { | ||||
| 		return errors.New("实现 sql.Scanner 接口 failed: type assertion to []byte failed") | ||||
| 	} | ||||
| 	return json.Unmarshal(bytes, o) | ||||
| } | ||||
| 
 | ||||
| // 校验Options是否合法,避免同一数字被多个规则覆盖
 | ||||
| func ValidateOptions(options PriceOptions) (bool, error) { | ||||
| 	symbolSet := map[string]struct{}{">": {}, "<": {}, ">=": {}, "<=": {}, "=": {}} | ||||
| 	cover := make(map[int]struct{}) | ||||
| 	for _, opt := range options { | ||||
| 		if opt.Num < 0 || opt.Num > 100 { | ||||
| 			return false, errors.New("数字范围错误") | ||||
| 
 | ||||
| 		} | ||||
| 		if _, ok := symbolSet[opt.Symbol]; !ok { | ||||
| 			return false, errors.New("符号错误") | ||||
| 
 | ||||
| 		} | ||||
| 		var nums []int | ||||
| 		switch opt.Symbol { | ||||
| 		case "=": | ||||
| 			nums = []int{int(opt.Num)} | ||||
| 		case ">": | ||||
| 			for i := int(opt.Num) + 1; i <= 100; i++ { | ||||
| 				nums = append(nums, i) | ||||
| 			} | ||||
| 		case ">=": | ||||
| 			for i := int(opt.Num); i <= 100; i++ { | ||||
| 				nums = append(nums, i) | ||||
| 			} | ||||
| 		case "<": | ||||
| 			for i := 1; i < int(opt.Num); i++ { | ||||
| 				nums = append(nums, i) | ||||
| 			} | ||||
| 		case "<=": | ||||
| 			for i := 1; i <= int(opt.Num); i++ { | ||||
| 				nums = append(nums, i) | ||||
| 			} | ||||
| 		} | ||||
| 		for _, n := range nums { | ||||
| 			if _, exist := cover[n]; exist { | ||||
| 				return false, errors.New("逻辑存在冲突,请重新设置") | ||||
| 
 | ||||
| 			} | ||||
| 			cover[n] = struct{}{} | ||||
| 		} | ||||
| 	} | ||||
| 	return true, nil | ||||
| } | ||||
| func (m *ValueAddService) TableName() string { | ||||
| 	return "value_add_service" | ||||
| } | ||||
| func (m *ValueAddServiceLang) TableName() string { | ||||
| 	return "value_add_service_lang" | ||||
| } | ||||
|  | ||||
							
								
								
									
										106
									
								
								pb/bundle.proto
									
									
									
									
									
								
							
							
						
						
									
										106
									
								
								pb/bundle.proto
									
									
									
									
									
								
							| @ -11,6 +11,13 @@ service Bundle { | ||||
|   rpc CreateBundle(BundleProfile) returns (CommonResponse) {} | ||||
|   rpc UpdateBundle(BundleProfile) returns (CommonResponse) {} | ||||
|   rpc DeleteBundle(DelBundleRequest) returns (CommonResponse) {} | ||||
|   rpc HandShelf(HandShelfRequest) returns(CommonResponse) {} //更新套餐上下架状态 | ||||
|   rpc SaveBundle(BundleProfile)returns (SaveResponse) {} | ||||
| 
 | ||||
| 
 | ||||
|   rpc BundleListV2(BundleListRequest) returns(BundleListResponse) {} | ||||
|   rpc BundleDetailV2(BundleDetailRequest) returns(BundleDetailResponseV2) {} | ||||
| 
 | ||||
| 
 | ||||
|   rpc BundleList(BundleListRequest) returns (BundleListResponse) {} | ||||
|   rpc BundleDetail(BundleDetailRequest) returns (BundleDetailResponse) {} | ||||
| @ -26,6 +33,11 @@ service Bundle { | ||||
|   rpc CreateValueAddBundle(CreateValueAddBundleRequest) returns (CreateValueAddBundleResponse) {} | ||||
|   rpc ValueAddBundleList(ValueAddBundleListRequest) returns (ValueAddBundleListResponse) {} | ||||
|   rpc ValueAddBundleDetail(ValueAddBundleDetailRequest) returns (ValueAddBundleDetailResponse) {} | ||||
| 
 | ||||
|   //新增值服务 | ||||
|   rpc SaveValueAddService(ValueAddServiceLang) returns (SaveResponse) {} | ||||
|   rpc ValueAddServiceList(ValueAddServiceListRequest) returns (ValueAddServiceListResponse) {} | ||||
|   rpc ValueAddServiceDetail(ValueAddServiceDetailRequest) returns (ValueAddServiceDetailResponse) {}   | ||||
| } | ||||
| 
 | ||||
| message CommonResponse { | ||||
| @ -47,8 +59,37 @@ message BundleProfile { | ||||
|   string companySign = 10 [json_name = "companySign"]; | ||||
|   int64  contractDuration = 11 [json_name = "contractDuration"]; | ||||
|   string bundleCommonUid = 12 [json_name = "bundleCommonUid"]; | ||||
|   int64 sort = 13 [json_name = "sort"]; | ||||
|   string bgImg1 = 14 [json_name = "bgImg1"]; | ||||
|   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"]; | ||||
| } | ||||
| message BundleProfileLang { | ||||
|   string uuid = 1 [json_name = "uuid"]; | ||||
|   string name = 2 [json_name = "name"]; | ||||
|   float  price = 3 [json_name = "price"]; | ||||
|   int64  priceType = 4 [json_name = "priceType"]; | ||||
|   string content = 5 [json_name = "content"]; | ||||
|   string language = 6 [json_name = "language"]; | ||||
|   string createdAt = 7 [json_name = "createdAt"]; | ||||
|   string updatedAt = 8 [json_name = "updatedAt"]; | ||||
|   string bgImg1 = 9 [json_name = "bgImg1"]; | ||||
|   string bgImg2 = 10 [json_name = "bgImg2"]; | ||||
|   int64 sort = 11 [json_name = "sort"]; | ||||
|   repeated ValueAddServiceLang valueAddServiceLang = 12 [json_name = "ValueAddServiceLang"]; | ||||
| } | ||||
| message SaveResponse { | ||||
|   string msg = 1 [json_name = "msg"]; | ||||
|   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"]; | ||||
| } | ||||
| 
 | ||||
| message DelBundleRequest { | ||||
|   string uuid = 1 [json_name = "uuid"]; | ||||
| } | ||||
| @ -68,13 +109,21 @@ message BundleListResponse { | ||||
| 
 | ||||
| message BundleDetailRequest { | ||||
|   string uuid = 1 [json_name = "uuid"]; | ||||
|   string language = 2 [json_name = "language"]; //语言 默认zh-CN,   zh-CN zh-TW EN de-DE js-JP | ||||
| } | ||||
| message HandShelfRequest { | ||||
|   string uuid = 1 [json_name = "uuid"]; | ||||
|   int64 shelfStatus = 2 [json_name = "shelfStatus"]; // 1 上架 2 下架 | ||||
| } | ||||
| 
 | ||||
| message BundleDetailResponse { | ||||
|   BundleProfile bundle = 1 [json_name = "bundle"]; | ||||
|   string msg = 2 [json_name = "msg"]; | ||||
| } | ||||
| 
 | ||||
| message BundleDetailResponseV2{ | ||||
|   BundleProfileLang bundle = 1 [json_name = "bundle"]; | ||||
|   repeated SelectValueAddService selectValueAddService = 2 [json_name = "SelectValueAddService"]; | ||||
|   string msg =3 [json_name = "msg"]; | ||||
| } | ||||
| message OrderRecord { | ||||
|   string uuid = 1 [json_name = "uuid"]; | ||||
|   string bundleUuid = 2 [json_name = "bundleUuid"]; | ||||
| @ -205,3 +254,54 @@ message ValueAddBundleDetailResponse { | ||||
| message FinancialConfirmationRequest { | ||||
|   string orderNo = 1 [json_name = "orderNo"]; | ||||
| } | ||||
| 
 | ||||
| // ****************************************************新增值服务*********************** | ||||
| //增值服务 | ||||
| message ValueAddService { | ||||
|   string uuid = 1 [json_name = "uuid"]; | ||||
|   string serviceName = 2 [json_name = "serviceName"]; //服务名称 | ||||
|   int32 serviceType = 3 [json_name = "serviceType"]; | ||||
|   repeated ValueAddServiceLang serviceLang = 4 [json_name = "serviceLang"]; | ||||
| } | ||||
| message ValueAddServiceLang { | ||||
|   string uuid = 1 [json_name = "uuid"]; | ||||
|   string serviceName = 2 [json_name = "serviceName"]; //服务名称 | ||||
|   int32 serviceType = 3 [json_name = "serviceType"]; | ||||
|   int32 priceMode = 4 [json_name = "priceMode"]; | ||||
|   string originalPrice = 5 [json_name = "originalPrice"]; | ||||
|   string unit = 6 [json_name = "unit"]; | ||||
|   int64  priceType = 7 [json_name = "priceType"]; | ||||
|   string language = 8 [json_name = "language"]; | ||||
|   string createdAt = 9 [json_name = "createdAt"]; | ||||
|   string updatedAt = 10 [json_name = "updatedAt"]; | ||||
|   repeated ValueAddPriceOptions options  = 12 [json_name = "options"]; | ||||
| } | ||||
| //增值服务价格选项 | ||||
| message ValueAddPriceOptions { | ||||
|  int64 id = 1 [json_name = "id"]; | ||||
|  int32 num = 2 [json_name = "num"]; | ||||
|  string symbol = 3 [json_name = "symbol"]; | ||||
|  string price = 4 [json_name = "price"]; | ||||
| } | ||||
| //增值服务列表 | ||||
| message ValueAddServiceListRequest { | ||||
|   int32 page = 1 [json_name = "page"]; | ||||
|   int32 pageSize = 2 [json_name = "pageSize"]; | ||||
|   string name = 3 [json_name = "name"]; | ||||
|   string language = 4 [json_name = "language"]; | ||||
| } | ||||
| message ValueAddServiceListResponse { | ||||
| int32 total = 1 [json_name = "total"]; | ||||
| string msg = 2 [json_name = "msg"]; | ||||
| repeated ValueAddService valueAddServiceList = 3 [json_name = "valueAddServiceList"]; | ||||
| } | ||||
| //增值服务详情 | ||||
| message ValueAddServiceDetailRequest { | ||||
|   string uuid = 1 [json_name = "uuid"]; | ||||
|   string language = 2 [json_name = "language"]; //语言 默认zh-CN,   zh-CN zh-TW EN de-DE js-JP | ||||
| } | ||||
| message ValueAddServiceDetailResponse { | ||||
|   string msg = 1 [json_name = "msg"]; | ||||
|   ValueAddServiceLang valueAddServiceLang = 2 [json_name = "valueAddServiceLang"]; | ||||
| } | ||||
| //*********************************新增值服务-over****************************************** | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -21,6 +21,36 @@ func (this *CommonResponse) Validate() error { | ||||
| 	return nil | ||||
| } | ||||
| func (this *BundleProfile) Validate() error { | ||||
| 	for _, item := range this.SelectValueAddService { | ||||
| 		if item != nil { | ||||
| 			if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil { | ||||
| 				return github_com_mwitkow_go_proto_validators.FieldError("SelectValueAddService", err) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	for _, item := range this.BundleProfileLang { | ||||
| 		if item != nil { | ||||
| 			if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil { | ||||
| 				return github_com_mwitkow_go_proto_validators.FieldError("BundleProfileLang", err) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
| func (this *BundleProfileLang) Validate() error { | ||||
| 	for _, item := range this.ValueAddServiceLang { | ||||
| 		if item != nil { | ||||
| 			if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil { | ||||
| 				return github_com_mwitkow_go_proto_validators.FieldError("ValueAddServiceLang", err) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
| func (this *SaveResponse) Validate() error { | ||||
| 	return nil | ||||
| } | ||||
| func (this *SelectValueAddService) Validate() error { | ||||
| 	return nil | ||||
| } | ||||
| func (this *DelBundleRequest) Validate() error { | ||||
| @ -42,6 +72,9 @@ func (this *BundleListResponse) Validate() error { | ||||
| func (this *BundleDetailRequest) Validate() error { | ||||
| 	return nil | ||||
| } | ||||
| func (this *HandShelfRequest) Validate() error { | ||||
| 	return nil | ||||
| } | ||||
| func (this *BundleDetailResponse) Validate() error { | ||||
| 	if this.Bundle != nil { | ||||
| 		if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Bundle); err != nil { | ||||
| @ -50,6 +83,21 @@ func (this *BundleDetailResponse) Validate() error { | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
| func (this *BundleDetailResponseV2) Validate() error { | ||||
| 	if this.Bundle != nil { | ||||
| 		if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Bundle); err != nil { | ||||
| 			return github_com_mwitkow_go_proto_validators.FieldError("Bundle", err) | ||||
| 		} | ||||
| 	} | ||||
| 	for _, item := range this.SelectValueAddService { | ||||
| 		if item != nil { | ||||
| 			if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil { | ||||
| 				return github_com_mwitkow_go_proto_validators.FieldError("SelectValueAddService", err) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
| func (this *OrderRecord) Validate() error { | ||||
| 	return nil | ||||
| } | ||||
| @ -119,3 +167,50 @@ func (this *ValueAddBundleDetailResponse) Validate() error { | ||||
| func (this *FinancialConfirmationRequest) Validate() error { | ||||
| 	return nil | ||||
| } | ||||
| func (this *ValueAddService) Validate() error { | ||||
| 	for _, item := range this.ServiceLang { | ||||
| 		if item != nil { | ||||
| 			if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil { | ||||
| 				return github_com_mwitkow_go_proto_validators.FieldError("ServiceLang", err) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
| func (this *ValueAddServiceLang) Validate() error { | ||||
| 	for _, item := range this.Options { | ||||
| 		if item != nil { | ||||
| 			if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil { | ||||
| 				return github_com_mwitkow_go_proto_validators.FieldError("Options", err) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
| func (this *ValueAddPriceOptions) Validate() error { | ||||
| 	return nil | ||||
| } | ||||
| func (this *ValueAddServiceListRequest) Validate() error { | ||||
| 	return nil | ||||
| } | ||||
| func (this *ValueAddServiceListResponse) Validate() error { | ||||
| 	for _, item := range this.ValueAddServiceList { | ||||
| 		if item != nil { | ||||
| 			if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil { | ||||
| 				return github_com_mwitkow_go_proto_validators.FieldError("ValueAddServiceList", err) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
| func (this *ValueAddServiceDetailRequest) Validate() error { | ||||
| 	return nil | ||||
| } | ||||
| func (this *ValueAddServiceDetailResponse) Validate() error { | ||||
| 	if this.ValueAddServiceLang != nil { | ||||
| 		if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.ValueAddServiceLang); err != nil { | ||||
| 			return github_com_mwitkow_go_proto_validators.FieldError("ValueAddServiceLang", err) | ||||
| 		} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| // Code generated by protoc-gen-go-triple. DO NOT EDIT.
 | ||||
| // versions:
 | ||||
| // - protoc-gen-go-triple v1.0.8
 | ||||
| // - protoc             v3.10.1
 | ||||
| // - protoc             v5.29.2
 | ||||
| // source: pb/bundle.proto
 | ||||
| 
 | ||||
| package bundle | ||||
| @ -31,6 +31,10 @@ type BundleClient interface { | ||||
| 	CreateBundle(ctx context.Context, in *BundleProfile, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment) | ||||
| 	UpdateBundle(ctx context.Context, in *BundleProfile, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment) | ||||
| 	DeleteBundle(ctx context.Context, in *DelBundleRequest, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment) | ||||
| 	HandShelf(ctx context.Context, in *HandShelfRequest, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment) | ||||
| 	SaveBundle(ctx context.Context, in *BundleProfile, opts ...grpc_go.CallOption) (*SaveResponse, common.ErrorWithAttachment) | ||||
| 	BundleListV2(ctx context.Context, in *BundleListRequest, opts ...grpc_go.CallOption) (*BundleListResponse, common.ErrorWithAttachment) | ||||
| 	BundleDetailV2(ctx context.Context, in *BundleDetailRequest, opts ...grpc_go.CallOption) (*BundleDetailResponseV2, common.ErrorWithAttachment) | ||||
| 	BundleList(ctx context.Context, in *BundleListRequest, opts ...grpc_go.CallOption) (*BundleListResponse, common.ErrorWithAttachment) | ||||
| 	BundleDetail(ctx context.Context, in *BundleDetailRequest, opts ...grpc_go.CallOption) (*BundleDetailResponse, common.ErrorWithAttachment) | ||||
| 	CreateOrderRecord(ctx context.Context, in *OrderRecord, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment) | ||||
| @ -43,6 +47,10 @@ type BundleClient interface { | ||||
| 	CreateValueAddBundle(ctx context.Context, in *CreateValueAddBundleRequest, opts ...grpc_go.CallOption) (*CreateValueAddBundleResponse, common.ErrorWithAttachment) | ||||
| 	ValueAddBundleList(ctx context.Context, in *ValueAddBundleListRequest, opts ...grpc_go.CallOption) (*ValueAddBundleListResponse, common.ErrorWithAttachment) | ||||
| 	ValueAddBundleDetail(ctx context.Context, in *ValueAddBundleDetailRequest, opts ...grpc_go.CallOption) (*ValueAddBundleDetailResponse, common.ErrorWithAttachment) | ||||
| 	//新增值服务
 | ||||
| 	SaveValueAddService(ctx context.Context, in *ValueAddServiceLang, opts ...grpc_go.CallOption) (*SaveResponse, common.ErrorWithAttachment) | ||||
| 	ValueAddServiceList(ctx context.Context, in *ValueAddServiceListRequest, opts ...grpc_go.CallOption) (*ValueAddServiceListResponse, common.ErrorWithAttachment) | ||||
| 	ValueAddServiceDetail(ctx context.Context, in *ValueAddServiceDetailRequest, opts ...grpc_go.CallOption) (*ValueAddServiceDetailResponse, common.ErrorWithAttachment) | ||||
| } | ||||
| 
 | ||||
| type bundleClient struct { | ||||
| @ -53,6 +61,10 @@ type BundleClientImpl struct { | ||||
| 	CreateBundle                      func(ctx context.Context, in *BundleProfile) (*CommonResponse, error) | ||||
| 	UpdateBundle                      func(ctx context.Context, in *BundleProfile) (*CommonResponse, error) | ||||
| 	DeleteBundle                      func(ctx context.Context, in *DelBundleRequest) (*CommonResponse, error) | ||||
| 	HandShelf                         func(ctx context.Context, in *HandShelfRequest) (*CommonResponse, error) | ||||
| 	SaveBundle                        func(ctx context.Context, in *BundleProfile) (*SaveResponse, error) | ||||
| 	BundleListV2                      func(ctx context.Context, in *BundleListRequest) (*BundleListResponse, error) | ||||
| 	BundleDetailV2                    func(ctx context.Context, in *BundleDetailRequest) (*BundleDetailResponseV2, error) | ||||
| 	BundleList                        func(ctx context.Context, in *BundleListRequest) (*BundleListResponse, error) | ||||
| 	BundleDetail                      func(ctx context.Context, in *BundleDetailRequest) (*BundleDetailResponse, error) | ||||
| 	CreateOrderRecord                 func(ctx context.Context, in *OrderRecord) (*CommonResponse, error) | ||||
| @ -64,6 +76,9 @@ type BundleClientImpl struct { | ||||
| 	CreateValueAddBundle              func(ctx context.Context, in *CreateValueAddBundleRequest) (*CreateValueAddBundleResponse, error) | ||||
| 	ValueAddBundleList                func(ctx context.Context, in *ValueAddBundleListRequest) (*ValueAddBundleListResponse, error) | ||||
| 	ValueAddBundleDetail              func(ctx context.Context, in *ValueAddBundleDetailRequest) (*ValueAddBundleDetailResponse, error) | ||||
| 	SaveValueAddService               func(ctx context.Context, in *ValueAddServiceLang) (*SaveResponse, error) | ||||
| 	ValueAddServiceList               func(ctx context.Context, in *ValueAddServiceListRequest) (*ValueAddServiceListResponse, error) | ||||
| 	ValueAddServiceDetail             func(ctx context.Context, in *ValueAddServiceDetailRequest) (*ValueAddServiceDetailResponse, error) | ||||
| } | ||||
| 
 | ||||
| func (c *BundleClientImpl) GetDubboStub(cc *triple.TripleConn) BundleClient { | ||||
| @ -96,6 +111,30 @@ func (c *bundleClient) DeleteBundle(ctx context.Context, in *DelBundleRequest, o | ||||
| 	return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/DeleteBundle", in, out) | ||||
| } | ||||
| 
 | ||||
| func (c *bundleClient) HandShelf(ctx context.Context, in *HandShelfRequest, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment) { | ||||
| 	out := new(CommonResponse) | ||||
| 	interfaceKey := ctx.Value(constant.InterfaceKey).(string) | ||||
| 	return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/HandShelf", in, out) | ||||
| } | ||||
| 
 | ||||
| func (c *bundleClient) SaveBundle(ctx context.Context, in *BundleProfile, opts ...grpc_go.CallOption) (*SaveResponse, common.ErrorWithAttachment) { | ||||
| 	out := new(SaveResponse) | ||||
| 	interfaceKey := ctx.Value(constant.InterfaceKey).(string) | ||||
| 	return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/SaveBundle", in, out) | ||||
| } | ||||
| 
 | ||||
| func (c *bundleClient) BundleListV2(ctx context.Context, in *BundleListRequest, opts ...grpc_go.CallOption) (*BundleListResponse, common.ErrorWithAttachment) { | ||||
| 	out := new(BundleListResponse) | ||||
| 	interfaceKey := ctx.Value(constant.InterfaceKey).(string) | ||||
| 	return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/BundleListV2", in, out) | ||||
| } | ||||
| 
 | ||||
| func (c *bundleClient) BundleDetailV2(ctx context.Context, in *BundleDetailRequest, opts ...grpc_go.CallOption) (*BundleDetailResponseV2, common.ErrorWithAttachment) { | ||||
| 	out := new(BundleDetailResponseV2) | ||||
| 	interfaceKey := ctx.Value(constant.InterfaceKey).(string) | ||||
| 	return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/BundleDetailV2", in, out) | ||||
| } | ||||
| 
 | ||||
| func (c *bundleClient) BundleList(ctx context.Context, in *BundleListRequest, opts ...grpc_go.CallOption) (*BundleListResponse, common.ErrorWithAttachment) { | ||||
| 	out := new(BundleListResponse) | ||||
| 	interfaceKey := ctx.Value(constant.InterfaceKey).(string) | ||||
| @ -162,6 +201,24 @@ func (c *bundleClient) ValueAddBundleDetail(ctx context.Context, in *ValueAddBun | ||||
| 	return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/ValueAddBundleDetail", in, out) | ||||
| } | ||||
| 
 | ||||
| func (c *bundleClient) SaveValueAddService(ctx context.Context, in *ValueAddServiceLang, opts ...grpc_go.CallOption) (*SaveResponse, common.ErrorWithAttachment) { | ||||
| 	out := new(SaveResponse) | ||||
| 	interfaceKey := ctx.Value(constant.InterfaceKey).(string) | ||||
| 	return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/SaveValueAddService", in, out) | ||||
| } | ||||
| 
 | ||||
| func (c *bundleClient) ValueAddServiceList(ctx context.Context, in *ValueAddServiceListRequest, opts ...grpc_go.CallOption) (*ValueAddServiceListResponse, common.ErrorWithAttachment) { | ||||
| 	out := new(ValueAddServiceListResponse) | ||||
| 	interfaceKey := ctx.Value(constant.InterfaceKey).(string) | ||||
| 	return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/ValueAddServiceList", in, out) | ||||
| } | ||||
| 
 | ||||
| func (c *bundleClient) ValueAddServiceDetail(ctx context.Context, in *ValueAddServiceDetailRequest, opts ...grpc_go.CallOption) (*ValueAddServiceDetailResponse, common.ErrorWithAttachment) { | ||||
| 	out := new(ValueAddServiceDetailResponse) | ||||
| 	interfaceKey := ctx.Value(constant.InterfaceKey).(string) | ||||
| 	return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/ValueAddServiceDetail", in, out) | ||||
| } | ||||
| 
 | ||||
| // BundleServer is the server API for Bundle service.
 | ||||
| // All implementations must embed UnimplementedBundleServer
 | ||||
| // for forward compatibility
 | ||||
| @ -169,6 +226,10 @@ type BundleServer interface { | ||||
| 	CreateBundle(context.Context, *BundleProfile) (*CommonResponse, error) | ||||
| 	UpdateBundle(context.Context, *BundleProfile) (*CommonResponse, error) | ||||
| 	DeleteBundle(context.Context, *DelBundleRequest) (*CommonResponse, error) | ||||
| 	HandShelf(context.Context, *HandShelfRequest) (*CommonResponse, error) | ||||
| 	SaveBundle(context.Context, *BundleProfile) (*SaveResponse, error) | ||||
| 	BundleListV2(context.Context, *BundleListRequest) (*BundleListResponse, error) | ||||
| 	BundleDetailV2(context.Context, *BundleDetailRequest) (*BundleDetailResponseV2, error) | ||||
| 	BundleList(context.Context, *BundleListRequest) (*BundleListResponse, error) | ||||
| 	BundleDetail(context.Context, *BundleDetailRequest) (*BundleDetailResponse, error) | ||||
| 	CreateOrderRecord(context.Context, *OrderRecord) (*CommonResponse, error) | ||||
| @ -181,6 +242,10 @@ type BundleServer interface { | ||||
| 	CreateValueAddBundle(context.Context, *CreateValueAddBundleRequest) (*CreateValueAddBundleResponse, error) | ||||
| 	ValueAddBundleList(context.Context, *ValueAddBundleListRequest) (*ValueAddBundleListResponse, error) | ||||
| 	ValueAddBundleDetail(context.Context, *ValueAddBundleDetailRequest) (*ValueAddBundleDetailResponse, error) | ||||
| 	//新增值服务
 | ||||
| 	SaveValueAddService(context.Context, *ValueAddServiceLang) (*SaveResponse, error) | ||||
| 	ValueAddServiceList(context.Context, *ValueAddServiceListRequest) (*ValueAddServiceListResponse, error) | ||||
| 	ValueAddServiceDetail(context.Context, *ValueAddServiceDetailRequest) (*ValueAddServiceDetailResponse, error) | ||||
| 	mustEmbedUnimplementedBundleServer() | ||||
| } | ||||
| 
 | ||||
| @ -198,6 +263,18 @@ func (UnimplementedBundleServer) UpdateBundle(context.Context, *BundleProfile) ( | ||||
| func (UnimplementedBundleServer) DeleteBundle(context.Context, *DelBundleRequest) (*CommonResponse, error) { | ||||
| 	return nil, status.Errorf(codes.Unimplemented, "method DeleteBundle not implemented") | ||||
| } | ||||
| func (UnimplementedBundleServer) HandShelf(context.Context, *HandShelfRequest) (*CommonResponse, error) { | ||||
| 	return nil, status.Errorf(codes.Unimplemented, "method HandShelf not implemented") | ||||
| } | ||||
| func (UnimplementedBundleServer) SaveBundle(context.Context, *BundleProfile) (*SaveResponse, error) { | ||||
| 	return nil, status.Errorf(codes.Unimplemented, "method SaveBundle not implemented") | ||||
| } | ||||
| func (UnimplementedBundleServer) BundleListV2(context.Context, *BundleListRequest) (*BundleListResponse, error) { | ||||
| 	return nil, status.Errorf(codes.Unimplemented, "method BundleListV2 not implemented") | ||||
| } | ||||
| func (UnimplementedBundleServer) BundleDetailV2(context.Context, *BundleDetailRequest) (*BundleDetailResponseV2, error) { | ||||
| 	return nil, status.Errorf(codes.Unimplemented, "method BundleDetailV2 not implemented") | ||||
| } | ||||
| func (UnimplementedBundleServer) BundleList(context.Context, *BundleListRequest) (*BundleListResponse, error) { | ||||
| 	return nil, status.Errorf(codes.Unimplemented, "method BundleList not implemented") | ||||
| } | ||||
| @ -231,6 +308,15 @@ func (UnimplementedBundleServer) ValueAddBundleList(context.Context, *ValueAddBu | ||||
| func (UnimplementedBundleServer) ValueAddBundleDetail(context.Context, *ValueAddBundleDetailRequest) (*ValueAddBundleDetailResponse, error) { | ||||
| 	return nil, status.Errorf(codes.Unimplemented, "method ValueAddBundleDetail not implemented") | ||||
| } | ||||
| func (UnimplementedBundleServer) SaveValueAddService(context.Context, *ValueAddServiceLang) (*SaveResponse, error) { | ||||
| 	return nil, status.Errorf(codes.Unimplemented, "method SaveValueAddService not implemented") | ||||
| } | ||||
| func (UnimplementedBundleServer) ValueAddServiceList(context.Context, *ValueAddServiceListRequest) (*ValueAddServiceListResponse, error) { | ||||
| 	return nil, status.Errorf(codes.Unimplemented, "method ValueAddServiceList not implemented") | ||||
| } | ||||
| func (UnimplementedBundleServer) ValueAddServiceDetail(context.Context, *ValueAddServiceDetailRequest) (*ValueAddServiceDetailResponse, error) { | ||||
| 	return nil, status.Errorf(codes.Unimplemented, "method ValueAddServiceDetail not implemented") | ||||
| } | ||||
| func (s *UnimplementedBundleServer) XXX_SetProxyImpl(impl protocol.Invoker) { | ||||
| 	s.proxyImpl = impl | ||||
| } | ||||
| @ -346,6 +432,122 @@ func _Bundle_DeleteBundle_Handler(srv interface{}, ctx context.Context, dec func | ||||
| 	return interceptor(ctx, in, info, handler) | ||||
| } | ||||
| 
 | ||||
| func _Bundle_HandShelf_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) { | ||||
| 	in := new(HandShelfRequest) | ||||
| 	if err := dec(in); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	base := srv.(dubbo3.Dubbo3GrpcService) | ||||
| 	args := []interface{}{} | ||||
| 	args = append(args, in) | ||||
| 	md, _ := metadata.FromIncomingContext(ctx) | ||||
| 	invAttachment := make(map[string]interface{}, len(md)) | ||||
| 	for k, v := range md { | ||||
| 		invAttachment[k] = v | ||||
| 	} | ||||
| 	invo := invocation.NewRPCInvocation("HandShelf", args, invAttachment) | ||||
| 	if interceptor == nil { | ||||
| 		result := base.XXX_GetProxyImpl().Invoke(ctx, invo) | ||||
| 		return result, result.Error() | ||||
| 	} | ||||
| 	info := &grpc_go.UnaryServerInfo{ | ||||
| 		Server:     srv, | ||||
| 		FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string), | ||||
| 	} | ||||
| 	handler := func(ctx context.Context, req interface{}) (interface{}, error) { | ||||
| 		result := base.XXX_GetProxyImpl().Invoke(ctx, invo) | ||||
| 		return result, result.Error() | ||||
| 	} | ||||
| 	return interceptor(ctx, in, info, handler) | ||||
| } | ||||
| 
 | ||||
| func _Bundle_SaveBundle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) { | ||||
| 	in := new(BundleProfile) | ||||
| 	if err := dec(in); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	base := srv.(dubbo3.Dubbo3GrpcService) | ||||
| 	args := []interface{}{} | ||||
| 	args = append(args, in) | ||||
| 	md, _ := metadata.FromIncomingContext(ctx) | ||||
| 	invAttachment := make(map[string]interface{}, len(md)) | ||||
| 	for k, v := range md { | ||||
| 		invAttachment[k] = v | ||||
| 	} | ||||
| 	invo := invocation.NewRPCInvocation("SaveBundle", args, invAttachment) | ||||
| 	if interceptor == nil { | ||||
| 		result := base.XXX_GetProxyImpl().Invoke(ctx, invo) | ||||
| 		return result, result.Error() | ||||
| 	} | ||||
| 	info := &grpc_go.UnaryServerInfo{ | ||||
| 		Server:     srv, | ||||
| 		FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string), | ||||
| 	} | ||||
| 	handler := func(ctx context.Context, req interface{}) (interface{}, error) { | ||||
| 		result := base.XXX_GetProxyImpl().Invoke(ctx, invo) | ||||
| 		return result, result.Error() | ||||
| 	} | ||||
| 	return interceptor(ctx, in, info, handler) | ||||
| } | ||||
| 
 | ||||
| func _Bundle_BundleListV2_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) { | ||||
| 	in := new(BundleListRequest) | ||||
| 	if err := dec(in); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	base := srv.(dubbo3.Dubbo3GrpcService) | ||||
| 	args := []interface{}{} | ||||
| 	args = append(args, in) | ||||
| 	md, _ := metadata.FromIncomingContext(ctx) | ||||
| 	invAttachment := make(map[string]interface{}, len(md)) | ||||
| 	for k, v := range md { | ||||
| 		invAttachment[k] = v | ||||
| 	} | ||||
| 	invo := invocation.NewRPCInvocation("BundleListV2", args, invAttachment) | ||||
| 	if interceptor == nil { | ||||
| 		result := base.XXX_GetProxyImpl().Invoke(ctx, invo) | ||||
| 		return result, result.Error() | ||||
| 	} | ||||
| 	info := &grpc_go.UnaryServerInfo{ | ||||
| 		Server:     srv, | ||||
| 		FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string), | ||||
| 	} | ||||
| 	handler := func(ctx context.Context, req interface{}) (interface{}, error) { | ||||
| 		result := base.XXX_GetProxyImpl().Invoke(ctx, invo) | ||||
| 		return result, result.Error() | ||||
| 	} | ||||
| 	return interceptor(ctx, in, info, handler) | ||||
| } | ||||
| 
 | ||||
| func _Bundle_BundleDetailV2_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) { | ||||
| 	in := new(BundleDetailRequest) | ||||
| 	if err := dec(in); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	base := srv.(dubbo3.Dubbo3GrpcService) | ||||
| 	args := []interface{}{} | ||||
| 	args = append(args, in) | ||||
| 	md, _ := metadata.FromIncomingContext(ctx) | ||||
| 	invAttachment := make(map[string]interface{}, len(md)) | ||||
| 	for k, v := range md { | ||||
| 		invAttachment[k] = v | ||||
| 	} | ||||
| 	invo := invocation.NewRPCInvocation("BundleDetailV2", args, invAttachment) | ||||
| 	if interceptor == nil { | ||||
| 		result := base.XXX_GetProxyImpl().Invoke(ctx, invo) | ||||
| 		return result, result.Error() | ||||
| 	} | ||||
| 	info := &grpc_go.UnaryServerInfo{ | ||||
| 		Server:     srv, | ||||
| 		FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string), | ||||
| 	} | ||||
| 	handler := func(ctx context.Context, req interface{}) (interface{}, error) { | ||||
| 		result := base.XXX_GetProxyImpl().Invoke(ctx, invo) | ||||
| 		return result, result.Error() | ||||
| 	} | ||||
| 	return interceptor(ctx, in, info, handler) | ||||
| } | ||||
| 
 | ||||
| func _Bundle_BundleList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) { | ||||
| 	in := new(BundleListRequest) | ||||
| 	if err := dec(in); err != nil { | ||||
| @ -665,6 +867,93 @@ func _Bundle_ValueAddBundleDetail_Handler(srv interface{}, ctx context.Context, | ||||
| 	return interceptor(ctx, in, info, handler) | ||||
| } | ||||
| 
 | ||||
| func _Bundle_SaveValueAddService_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) { | ||||
| 	in := new(ValueAddServiceLang) | ||||
| 	if err := dec(in); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	base := srv.(dubbo3.Dubbo3GrpcService) | ||||
| 	args := []interface{}{} | ||||
| 	args = append(args, in) | ||||
| 	md, _ := metadata.FromIncomingContext(ctx) | ||||
| 	invAttachment := make(map[string]interface{}, len(md)) | ||||
| 	for k, v := range md { | ||||
| 		invAttachment[k] = v | ||||
| 	} | ||||
| 	invo := invocation.NewRPCInvocation("SaveValueAddService", args, invAttachment) | ||||
| 	if interceptor == nil { | ||||
| 		result := base.XXX_GetProxyImpl().Invoke(ctx, invo) | ||||
| 		return result, result.Error() | ||||
| 	} | ||||
| 	info := &grpc_go.UnaryServerInfo{ | ||||
| 		Server:     srv, | ||||
| 		FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string), | ||||
| 	} | ||||
| 	handler := func(ctx context.Context, req interface{}) (interface{}, error) { | ||||
| 		result := base.XXX_GetProxyImpl().Invoke(ctx, invo) | ||||
| 		return result, result.Error() | ||||
| 	} | ||||
| 	return interceptor(ctx, in, info, handler) | ||||
| } | ||||
| 
 | ||||
| func _Bundle_ValueAddServiceList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) { | ||||
| 	in := new(ValueAddServiceListRequest) | ||||
| 	if err := dec(in); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	base := srv.(dubbo3.Dubbo3GrpcService) | ||||
| 	args := []interface{}{} | ||||
| 	args = append(args, in) | ||||
| 	md, _ := metadata.FromIncomingContext(ctx) | ||||
| 	invAttachment := make(map[string]interface{}, len(md)) | ||||
| 	for k, v := range md { | ||||
| 		invAttachment[k] = v | ||||
| 	} | ||||
| 	invo := invocation.NewRPCInvocation("ValueAddServiceList", args, invAttachment) | ||||
| 	if interceptor == nil { | ||||
| 		result := base.XXX_GetProxyImpl().Invoke(ctx, invo) | ||||
| 		return result, result.Error() | ||||
| 	} | ||||
| 	info := &grpc_go.UnaryServerInfo{ | ||||
| 		Server:     srv, | ||||
| 		FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string), | ||||
| 	} | ||||
| 	handler := func(ctx context.Context, req interface{}) (interface{}, error) { | ||||
| 		result := base.XXX_GetProxyImpl().Invoke(ctx, invo) | ||||
| 		return result, result.Error() | ||||
| 	} | ||||
| 	return interceptor(ctx, in, info, handler) | ||||
| } | ||||
| 
 | ||||
| func _Bundle_ValueAddServiceDetail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) { | ||||
| 	in := new(ValueAddServiceDetailRequest) | ||||
| 	if err := dec(in); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	base := srv.(dubbo3.Dubbo3GrpcService) | ||||
| 	args := []interface{}{} | ||||
| 	args = append(args, in) | ||||
| 	md, _ := metadata.FromIncomingContext(ctx) | ||||
| 	invAttachment := make(map[string]interface{}, len(md)) | ||||
| 	for k, v := range md { | ||||
| 		invAttachment[k] = v | ||||
| 	} | ||||
| 	invo := invocation.NewRPCInvocation("ValueAddServiceDetail", args, invAttachment) | ||||
| 	if interceptor == nil { | ||||
| 		result := base.XXX_GetProxyImpl().Invoke(ctx, invo) | ||||
| 		return result, result.Error() | ||||
| 	} | ||||
| 	info := &grpc_go.UnaryServerInfo{ | ||||
| 		Server:     srv, | ||||
| 		FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string), | ||||
| 	} | ||||
| 	handler := func(ctx context.Context, req interface{}) (interface{}, error) { | ||||
| 		result := base.XXX_GetProxyImpl().Invoke(ctx, invo) | ||||
| 		return result, result.Error() | ||||
| 	} | ||||
| 	return interceptor(ctx, in, info, handler) | ||||
| } | ||||
| 
 | ||||
| // Bundle_ServiceDesc is the grpc_go.ServiceDesc for Bundle service.
 | ||||
| // It's only intended for direct use with grpc_go.RegisterService,
 | ||||
| // and not to be introspected or modified (even as a copy)
 | ||||
| @ -684,6 +973,22 @@ var Bundle_ServiceDesc = grpc_go.ServiceDesc{ | ||||
| 			MethodName: "DeleteBundle", | ||||
| 			Handler:    _Bundle_DeleteBundle_Handler, | ||||
| 		}, | ||||
| 		{ | ||||
| 			MethodName: "HandShelf", | ||||
| 			Handler:    _Bundle_HandShelf_Handler, | ||||
| 		}, | ||||
| 		{ | ||||
| 			MethodName: "SaveBundle", | ||||
| 			Handler:    _Bundle_SaveBundle_Handler, | ||||
| 		}, | ||||
| 		{ | ||||
| 			MethodName: "BundleListV2", | ||||
| 			Handler:    _Bundle_BundleListV2_Handler, | ||||
| 		}, | ||||
| 		{ | ||||
| 			MethodName: "BundleDetailV2", | ||||
| 			Handler:    _Bundle_BundleDetailV2_Handler, | ||||
| 		}, | ||||
| 		{ | ||||
| 			MethodName: "BundleList", | ||||
| 			Handler:    _Bundle_BundleList_Handler, | ||||
| @ -728,6 +1033,18 @@ var Bundle_ServiceDesc = grpc_go.ServiceDesc{ | ||||
| 			MethodName: "ValueAddBundleDetail", | ||||
| 			Handler:    _Bundle_ValueAddBundleDetail_Handler, | ||||
| 		}, | ||||
| 		{ | ||||
| 			MethodName: "SaveValueAddService", | ||||
| 			Handler:    _Bundle_SaveValueAddService_Handler, | ||||
| 		}, | ||||
| 		{ | ||||
| 			MethodName: "ValueAddServiceList", | ||||
| 			Handler:    _Bundle_ValueAddServiceList_Handler, | ||||
| 		}, | ||||
| 		{ | ||||
| 			MethodName: "ValueAddServiceDetail", | ||||
| 			Handler:    _Bundle_ValueAddServiceDetail_Handler, | ||||
| 		}, | ||||
| 	}, | ||||
| 	Streams:  []grpc_go.StreamDesc{}, | ||||
| 	Metadata: "pb/bundle.proto", | ||||
|  | ||||
| @ -1,10 +1,11 @@ | ||||
| package db | ||||
| 
 | ||||
| import ( | ||||
| 	"github.com/google/wire" | ||||
| 	"gorm.io/gorm" | ||||
| 	bundleConfig "micro-bundle/config" | ||||
| 	"strings" | ||||
| 
 | ||||
| 	"github.com/google/wire" | ||||
| 	"gorm.io/gorm" | ||||
| ) | ||||
| 
 | ||||
| var Provider = wire.NewSet(NewBundleDB) | ||||
|  | ||||
| @ -45,6 +45,10 @@ func loadMysqlConn(conn string) *gorm.DB { | ||||
| 		&model.BundleOrderRecords{}, | ||||
| 		&model.ValueAddBundleProfile{}, | ||||
| 		//&model.ValueAddBundleRecord{}
 | ||||
| 		&model.BundleProfileLang{}, | ||||
| 		&model.ValueAddService{}, | ||||
| 		&model.ValueAddServiceLang{}, | ||||
| 		&model.BundleToValueAddService{}, | ||||
| 	) | ||||
| 
 | ||||
| 	if err != nil { | ||||
|  | ||||
| @ -10,6 +10,13 @@ const ( | ||||
| 	Success = "操作成功" | ||||
| 	Failed  = "操作失败" | ||||
| ) | ||||
| const ( | ||||
| 	ZH_CN = "zh-CN" //简体中文
 | ||||
| 	ZH_TW = "zh-TW" //繁体中文
 | ||||
| 	EN    = "EN"    //英文
 | ||||
| 	DE_DE = "de-DE" //德语
 | ||||
| 	JS_JP = "js-JP" //日语
 | ||||
| ) | ||||
| 
 | ||||
| const ( | ||||
| 	Http          = 200 | ||||
| @ -72,3 +79,20 @@ const ( | ||||
| 	ErrorTransaction       = "事务失败" | ||||
| 	ErrorCommitTransaction = "提交事务失败" | ||||
| ) | ||||
| 
 | ||||
| // 增值服务信息
 | ||||
| const ( | ||||
| 	ErrorCreateValueAddServiceInfo   = "创建增值服务信息失败" | ||||
| 	SuccessCreateValueAddServiceInfo = "创建增值服务信息成功" | ||||
| 	ErrorUpdateValueAddServiceInfo   = "更新增值服务信息失败" | ||||
| 	SuccessUpdateValueAddServiceInfo = "更新增值服务信息成功" | ||||
| 	ErrorValueAddServiceList         = "获取增值服务列表失败" | ||||
| 	SuccessValueAddServiceList       = "获取增值服务列表成功" | ||||
| 	ErrorValueAddServiceInfo         = "获取增值服务详情失败" | ||||
| 	SuccessValueAddServiceInfo       = "获取增值服务详情成功" | ||||
| 	//校验
 | ||||
| 	ErrorValueServiceNameEmpty      = "增值服务名称不能为空" | ||||
| 	ErrorValueServiceTypeEmpty      = "增值服务类型不能为空" | ||||
| 	ErrorValueServicePriceModeEmpty = "增值服务价格模式不能为空" | ||||
| 	ErrorValueServiceOptionsEmpty   = "增值服务选项不能为空" | ||||
| ) | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user