|
|
@@ -234,6 +234,30 @@ func GetProductByIdAndProvince(id int64, province string, useCache bool) *Produc
|
|
|
return item
|
|
|
}
|
|
|
|
|
|
+//判断商品是否在当前省受限
|
|
|
+func GetNoDeliveryPrd(id int64, province string, useCache bool) *Product {
|
|
|
+ //k := fmt.Sprintf("product_model.GetProductById[%d]", id)
|
|
|
+ k := cache.GetKey(cache.GetNoDeliveryPrd, id, province)
|
|
|
+ if useCache {
|
|
|
+ if v, ok := cache.Cache.Get(k).(*Product); ok {
|
|
|
+ return v
|
|
|
+ }
|
|
|
+ }
|
|
|
+ item := new(Product)
|
|
|
+ sql := `
|
|
|
+ select id from
|
|
|
+ products
|
|
|
+ where id = ? and find_in_set(?,no_delivery_area);
|
|
|
+ `
|
|
|
+ err := orm.NewOrm().Raw(sql, id, province).QueryRow(&item)
|
|
|
+ if err != nil {
|
|
|
+ beego.BeeLogger.Warn("product_model.GetNoDeliveryPrd(%d) err=%s", id, province, err)
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ cache.Cache.Put(k, item, 5*time.Minute)
|
|
|
+ return item
|
|
|
+}
|
|
|
+
|
|
|
func GetProductsByCatId(cId, page, perPage, priceSort, saleSort int64, words string, useCache bool) (products []*Product) {
|
|
|
k := fmt.Sprintf("product_model.GetProductsByCatId(%d).page(%d).perPage(%d).words(%d)", cId, page, perPage, words)
|
|
|
if useCache {
|