From bdc9706125f75479eff1cae203897bec5b3c6c68 Mon Sep 17 00:00:00 2001 From: sxy <3187870250@qq.com> Date: Thu, 19 Jun 2025 16:16:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/controller/bundleV2.go | 8 +- internal/dao/bundleDao.go | 159 ++++++++++++++++---------------- internal/logic/bundleLogic.go | 16 ++-- 3 files changed, 92 insertions(+), 91 deletions(-) diff --git a/internal/controller/bundleV2.go b/internal/controller/bundleV2.go index 4c3b372..90389ac 100644 --- a/internal/controller/bundleV2.go +++ b/internal/controller/bundleV2.go @@ -44,7 +44,7 @@ func (b *BundleProvider) BatchGetValueAddServiceLang(ctx context.Context, req *b return logic.BatchGetValueAddServiceLang(req) } -// 增加h5套餐列表 -func (b *BundleProvider) BundleListH5V2(_ context.Context, req *bundle.BundleListRequest) (res *bundle.BundleListResponse, err error) { - return logic.BundleListH5V2(req) -} +// // 增加h5套餐列表 +// func (b *BundleProvider) BundleListH5V2(_ context.Context, req *bundle.BundleListRequest) (res *bundle.BundleListResponse, err error) { +// return logic.BundleListH5V2(req) +// } diff --git a/internal/dao/bundleDao.go b/internal/dao/bundleDao.go index 4adceac..aed9de6 100644 --- a/internal/dao/bundleDao.go +++ b/internal/dao/bundleDao.go @@ -343,94 +343,95 @@ func GetBundleDetailByUuid(uuid string) (*model.BundleProfile, error) { func CreateBunldeHistory(tx *gorm.DB, req *model.BundleProfileHistory) error { return tx.Model(&model.BundleProfileHistory{}).Create(req).Error } -func BundleListH5V2(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{}).Where("shelf_status = ?", 1).Preload("BundleProfileLang") - //query = query.Where("shelf_status = ?", 1) //上架的 +// func BundleListH5V2(req *bundle.BundleListRequest) (res *bundle.BundleListResponse, err error) { +// res = new(bundle.BundleListResponse) +// res.Bundles = make([]*bundle.BundleProfile, 0) +// bundles := make([]*model.BundleProfile, 0) - if req.Name != "" { - query = query.Where("name like ?", "%"+req.Name+"%") - } +// query := app.ModuleClients.BundleDB.Model(&model.BundleProfile{}).Where("shelf_status = ?", 1).Preload("BundleProfileLang") +// //query = query.Where("shelf_status = ?", 1) //上架的 - if req.Content != "" { - query = query.Where("content like ?", "%"+req.Content+"%") - } +// if req.Name != "" { +// query = query.Where("name like ?", "%"+req.Name+"%") +// } - if req.Language != "" { - query = query.Where("language like ?", req.Language) - } +// if req.Content != "" { +// query = query.Where("content like ?", "%"+req.Content+"%") +// } - count := *query +// if req.Language != "" { +// query = query.Where("language like ?", req.Language) +// } - // 排序: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)) - } +// count := *query - if err = query.Preload("BundleToValueAddService").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.BundleToValueAddService != nil { - for _, v := range bundleProfile.BundleToValueAddService { - selectValueAddService = append(selectValueAddService, &bundle.SelectValueAddService{ - ValueAddUuid: v.ValueUid, - IsDisplay: v.IsDisplay, - }) - } - } - 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, - ImgOption: int32(bundleProfile.ImgOption), - BgImg1: bundleProfile.BgImg1, - BgImg2: bundleProfile.BgImg2, - SelectValueAddService: selectValueAddService, - BundleProfileLang: bundleProfileLang, - ShelfStatus: int64(bundleProfile.ShelfStatus), - FontColor: bundleProfile.FontColor, - }) - } - } +// // 排序: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)) +// } - var total int64 +// if err = query.Preload("BundleToValueAddService").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.BundleToValueAddService != nil { +// for _, v := range bundleProfile.BundleToValueAddService { +// selectValueAddService = append(selectValueAddService, &bundle.SelectValueAddService{ +// ValueAddUuid: v.ValueUid, +// IsDisplay: v.IsDisplay, +// }) +// } +// } +// 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, +// ImgOption: int32(bundleProfile.ImgOption), +// BgImg1: bundleProfile.BgImg1, +// BgImg2: bundleProfile.BgImg2, +// SelectValueAddService: selectValueAddService, +// BundleProfileLang: bundleProfileLang, +// ShelfStatus: int64(bundleProfile.ShelfStatus), +// FontColor: bundleProfile.FontColor, +// }) +// } +// } - count.Count(&total) +// var total int64 - res.Total = int32(total) +// count.Count(&total) - return +// res.Total = int32(total) -} +// return + +// } diff --git a/internal/logic/bundleLogic.go b/internal/logic/bundleLogic.go index fa2de70..82b3d1c 100644 --- a/internal/logic/bundleLogic.go +++ b/internal/logic/bundleLogic.go @@ -528,11 +528,11 @@ func saveBundleHistory(tx *gorm.DB, bundleUuid string, operator string, operator } // 增加h5套餐列表 -func BundleListH5V2(req *bundle.BundleListRequest) (res *bundle.BundleListResponse, err error) { - res = new(bundle.BundleListResponse) - res, err = dao.BundleListH5V2(req) - if err != nil { - return res, errors.New("获取套餐列表失败") - } - return res, nil -} +// func BundleListH5V2(req *bundle.BundleListRequest) (res *bundle.BundleListResponse, err error) { +// res = new(bundle.BundleListResponse) +// res, err = dao.BundleListH5V2(req) +// if err != nil { +// return res, errors.New("获取套餐列表失败") +// } +// return res, nil +// }