From 8f2cedd984e4bd288326afe01041271faccf9d3f Mon Sep 17 00:00:00 2001 From: howell <2827207845@qq.com> Date: Tue, 22 Feb 2022 14:07:26 +0800 Subject: [PATCH] fix:sql error --- internal/api/mobile/goods/common_list.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/internal/api/mobile/goods/common_list.go b/internal/api/mobile/goods/common_list.go index f677514..99162d4 100755 --- a/internal/api/mobile/goods/common_list.go +++ b/internal/api/mobile/goods/common_list.go @@ -90,12 +90,15 @@ func QueryGoodsListByComprehension(c *gin.Context) { } var goodsList []goods.Information + status := 1 + if p.IsSale { + status = 0 + } q3 := mysql2.Db.Table("recook_goods_info as a"). Order("id desc").Where(goods.Information{ BrandID: p.BrandID, SecondCategoryID: p.SecondCategoryID, - PublishStatus: 1, - Country: p.CountryId, + PublishStatus: uint(status), }) if p.ActivityID != 0 { // 批发活动id @@ -146,12 +149,17 @@ func QueryGoodsListBySalesVolume(c *gin.Context) { return } + status := 1 + if p.IsSale { + status = 0 + } + var goodsList []goods.Information order := fmt.Sprintf("sales_volume %s, id desc", p.Order) q3 := mysql2.Db.Table("recook_goods_info as a").Order(order).Where(goods.Information{ BrandID: p.BrandID, SecondCategoryID: p.SecondCategoryID, - PublishStatus: 1, + PublishStatus: uint(status), Country: p.CountryId, }) if p.ActivityID != 0 { @@ -175,11 +183,15 @@ func QueryGoodsListByDiscountPrice(c *gin.Context) { } var goodsIdList []uint + status := 1 + if p.IsSale { + status = 0 + } var goodsInfoIdList []goods.Information q3 := mysql2.Db.Table("recook_goods_info as a").Where(goods.Information{ BrandID: p.BrandID, SecondCategoryID: p.SecondCategoryID, - PublishStatus: 1, + PublishStatus: uint(status), Country: p.CountryId, })