|
|
@@ -104,7 +104,7 @@ type Product struct {
|
|
|
}
|
|
|
|
|
|
//获取最新推荐商品
|
|
|
-func GetLatest(page, perPage, recommend int64, useCache bool) (products []*Product) {
|
|
|
+func GetLatest(page, perPage, recommend int64, ptype string, useCache bool) (products []*Product) {
|
|
|
k := fmt.Sprintf("product_model.GetLatest.page(%d).perPage(%d).recommend(%d)", page, perPage, recommend)
|
|
|
if useCache {
|
|
|
if ret, ok := cache.Cache.Get(k).([]*Product); ok {
|
|
|
@@ -113,7 +113,7 @@ func GetLatest(page, perPage, recommend int64, useCache bool) (products []*Produ
|
|
|
}
|
|
|
o := orm.NewOrm()
|
|
|
_, err := o.QueryTable(new(Product)).Filter("status", 1).
|
|
|
- Filter("recommend__gt", recommend).Filter("show_flag", true).
|
|
|
+ Filter("recommend__gt", recommend).Filter("show_flag", true).Filter("ptype", ptype).
|
|
|
OrderBy("-recommend", "-created_at").
|
|
|
Limit(perPage, (page-1)*perPage).
|
|
|
All(&products)
|
|
|
@@ -131,7 +131,7 @@ func GetLatest(page, perPage, recommend int64, useCache bool) (products []*Produ
|
|
|
return products
|
|
|
}
|
|
|
|
|
|
-func GetLatestCount(recommend int64, useCache bool) int64 {
|
|
|
+func GetLatestCount(recommend int64, ptype string, useCache bool) int64 {
|
|
|
k := fmt.Sprintf("product_model.GetLatestCount.recommend(%d)", recommend)
|
|
|
if useCache {
|
|
|
if ret, ok := cache.Cache.Get(k).(int64); ok {
|
|
|
@@ -140,7 +140,7 @@ func GetLatestCount(recommend int64, useCache bool) int64 {
|
|
|
}
|
|
|
item := new(Product)
|
|
|
o := orm.NewOrm()
|
|
|
- count, _ := o.QueryTable(item).Filter("recommend__gt", recommend).Filter("show_flag", true).Filter("status", 1).Count()
|
|
|
+ count, _ := o.QueryTable(item).Filter("recommend__gt", recommend).Filter("show_flag", true).Filter("ptype", ptype).Filter("status", 1).Count()
|
|
|
|
|
|
cache.Cache.Put(k, count, 10*time.Minute)
|
|
|
return count
|
|
|
@@ -172,7 +172,7 @@ func GetProductsByCatId(cId, page, perPage int64, useCache bool) (products []*Pr
|
|
|
}
|
|
|
}
|
|
|
o := orm.NewOrm()
|
|
|
- qs := o.QueryTable(new(Product)).Filter("status", 1).Filter("show_flag", true)
|
|
|
+ qs := o.QueryTable(new(Product)).Filter("status", 1).Filter("show_flag", true).Filter("ptype", TYPE_DIRECT_SALE)
|
|
|
if cId != 0 {
|
|
|
qs = qs.Filter("category_id", cId)
|
|
|
} else {
|
|
|
@@ -209,7 +209,7 @@ func GetProductCountByCatId(cId int64, useCache bool) int64 {
|
|
|
} else {
|
|
|
qs = qs.Exclude("category_id", 3) //3为审核类别,暂写死
|
|
|
}
|
|
|
- count, _ := qs.Filter("status", 1).Filter("show_flag", true).Count()
|
|
|
+ count, _ := qs.Filter("status", 1).Filter("show_flag", true).Filter("ptype", TYPE_DIRECT_SALE).Count()
|
|
|
|
|
|
cache.Cache.Put(k, count, 10*time.Minute)
|
|
|
return count
|