This commit is contained in:
laodaming
2023-07-20 18:04:50 +08:00
parent 2f5ce8dd77
commit 0e752e31fd
2 changed files with 15 additions and 17 deletions

View File

@@ -18,7 +18,7 @@ func (r *FsProductRecommendModel) GetRecommendProductList(req GetRecommendProduc
Table("fs_product_recommend as r").
Joins("inner join fs_product as p on r.product_id = p.id").
Where("r.status = ? ", 1).
Where("and p.is_shelf = ? and p.is_del = ? and p.status = ?", 1, 0, 1)
Where("p.is_shelf = ? and p.is_del = ? and p.status = ?", 1, 0, 1)
if req.Category != 0 {
db = db.Where("r.category = ?", req.Category)
}
@@ -29,10 +29,14 @@ func (r *FsProductRecommendModel) GetRecommendProductList(req GetRecommendProduc
err = db.Offset(offset).Limit(req.Limit).Find(&resp).Error
return resp, total, err
}
func (r *FsProductRecommendModel) GetIgnoreRandomRecommendProductList(ctx context.Context, limit int, category int64, idNotInt []int64) (resp []FsProductRecommend, err error) {
err = r.db.WithContext(ctx).Model(&FsProductRecommend{}).
Where("`product_id` not in(?) and `category` = ? and `status` = ?", idNotInt, category, 1).
Order("RAND()").Limit(limit).Find(&resp).Error
func (r *FsProductRecommendModel) GetIgnoreRandomRecommendProductList(ctx context.Context, limit int, category int64, idNotInt []int64) (resp []FsProduct, err error) {
err = r.db.WithContext(ctx).Debug().Select("p.*").
Table("fs_product_recommend as r").
Joins("inner join fs_product as p on r.product_id = p.id").
Where("r.product_id not in (?)", idNotInt).
Where("r.status = ? ", 1).
Where("p.is_shelf = ? and p.is_del = ? and p.status = ?", 1, 0, 1).
Where("r.category = ?", category).Order("RAND()").Limit(limit).Find(&resp).Error
return resp, err
}
func (r *FsProductRecommendModel) CreateOrUpdate(ctx context.Context, productId int64, category int64, data *FsProductRecommend) error {