|
@@ -124,6 +124,7 @@ type Product struct {
|
|
|
Silver int64 `orm:"column(silver)" json:"silver"` // varchar(255)
|
|
Silver int64 `orm:"column(silver)" json:"silver"` // varchar(255)
|
|
|
SaleZone int64 `orm:"column(sale_zone)" json:"sale_zone"` // 销售区
|
|
SaleZone int64 `orm:"column(sale_zone)" json:"sale_zone"` // 销售区
|
|
|
SaleZoneName string `orm:"-" json:"sale_zone_name"` // 销售区名称
|
|
SaleZoneName string `orm:"-" json:"sale_zone_name"` // 销售区名称
|
|
|
|
|
+ CanBuy bool `orm:"-" json:"can_buy"` // bool
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//获取最新推荐商品
|
|
//获取最新推荐商品
|
|
@@ -676,3 +677,26 @@ func DepartGetProductCountByCatId(cId, saleZone, depart int64, words string, use
|
|
|
cache.Cache.Put(k, ret.Count, 10*time.Minute)
|
|
cache.Cache.Put(k, ret.Count, 10*time.Minute)
|
|
|
return ret.Count
|
|
return ret.Count
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+func DecideCanBuy(pid, depart int64) bool {
|
|
|
|
|
+
|
|
|
|
|
+ type Ret struct {
|
|
|
|
|
+ Count int64 `json:"count"` //总数
|
|
|
|
|
+ }
|
|
|
|
|
+ ret := &Ret{}
|
|
|
|
|
+ o := orm.NewOrm()
|
|
|
|
|
+ sql := `
|
|
|
|
|
+ select count(DISTINCT a.id) as count from products a left join depart_records_products b on a.id=b.product_id
|
|
|
|
|
+ where a.id = ? and (b.depart_record_id=? or b.depart_record_id is null )
|
|
|
|
|
+
|
|
|
|
|
+ `
|
|
|
|
|
+ err := o.Raw(sql, pid, depart).QueryRow(ret)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ beego.BeeLogger.Error("GetLatestCount, depart:%d, err=[%s]", depart, err)
|
|
|
|
|
+ return false
|
|
|
|
|
+ }
|
|
|
|
|
+ if ret.Count <= 0 {
|
|
|
|
|
+ return false
|
|
|
|
|
+ }
|
|
|
|
|
+ return true
|
|
|
|
|
+}
|