|
@@ -60,16 +60,16 @@ class brand_dict extends words
|
|
|
|
|
|
class category_dict extends words
|
|
|
{
|
|
|
- private $gc_hot; //一个GC对应一个HotID
|
|
|
- private $hot_tree; //HOT的父子关系
|
|
|
+ private $mGcHot; //一个GC对应一个HotID
|
|
|
+ private $mHoTree; //HOT的父子关系
|
|
|
|
|
|
private $mHotBrand;
|
|
|
private $mHotCommon;
|
|
|
|
|
|
public function __construct() {
|
|
|
parent::__construct();
|
|
|
- $this->gc_hot = new one_one();
|
|
|
- $this->hot_tree = new array_tree();
|
|
|
+ $this->mGcHot = new one_one();
|
|
|
+ $this->mHoTree = new array_tree();
|
|
|
$this->mHotBrand = new one_multi();
|
|
|
$this->mHotCommon = new one_multi();
|
|
|
|
|
@@ -81,7 +81,7 @@ class category_dict extends words
|
|
|
foreach ($cats as $item)
|
|
|
{
|
|
|
$hot_id = intval($item['hot_id']);
|
|
|
- $this->hot_tree->add($hot_id,0);
|
|
|
+ $this->mHoTree->add($hot_id,0);
|
|
|
|
|
|
$name = $item['name'];
|
|
|
$this->parase($name,$hot_id);
|
|
@@ -89,7 +89,7 @@ class category_dict extends words
|
|
|
foreach($item['subitem'] as $sub_item) {
|
|
|
$subhot_id = intval($sub_item['hot_id']);
|
|
|
|
|
|
- $this->hot_tree->add($subhot_id,$hot_id);
|
|
|
+ $this->mHoTree->add($subhot_id,$hot_id);
|
|
|
|
|
|
$cids = category_helper::instance()->cids($subhot_id);
|
|
|
$this->add_gc_hot($cids,$subhot_id);
|
|
@@ -99,12 +99,55 @@ class category_dict extends words
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- public function brands($hotid) {
|
|
|
- return $this->mHotBrand->get($hotid);
|
|
|
+ public function brands($hotid)
|
|
|
+ {
|
|
|
+ if($this->mHoTree->is_parent($hotid) == false) {
|
|
|
+ return $this->mHotBrand->get($hotid);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ $sub_hots = $this->mHoTree->subs($hotid);
|
|
|
+
|
|
|
+ $pos = 0;
|
|
|
+ $brands = [];
|
|
|
+ foreach ($sub_hots as $hot)
|
|
|
+ {
|
|
|
+ if($pos == 0) {
|
|
|
+ $brands = $this->mHotBrand->get($hot);
|
|
|
+ } else {
|
|
|
+ $tmp = $this->mHotBrand->get($hot);
|
|
|
+ $brands = algorithm::set_union($brands,$tmp);
|
|
|
+ }
|
|
|
+ $pos++;
|
|
|
+ }
|
|
|
+ return $brands;
|
|
|
+ }
|
|
|
}
|
|
|
- public function commons($hotid) {
|
|
|
- return $this->mHotCommon->get($hotid);
|
|
|
+ public function commons($hotid)
|
|
|
+ {
|
|
|
+ if($this->mHoTree->is_parent($hotid) == false) {
|
|
|
+ return $this->mHotCommon->get($hotid);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ $sub_hots = $this->mHoTree->subs($hotid);
|
|
|
+
|
|
|
+ $pos = 0;
|
|
|
+ $cids = [];
|
|
|
+ foreach ($sub_hots as $hot)
|
|
|
+ {
|
|
|
+ if($pos == 0) {
|
|
|
+ $cids = $this->mHotCommon->get($hot);
|
|
|
+ } else {
|
|
|
+ $tmp = $this->mHotCommon->get($hot);
|
|
|
+ $cids = algorithm::set_union($cids,$tmp);
|
|
|
+ }
|
|
|
+ $pos++;
|
|
|
+ }
|
|
|
+ return $cids;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
public function add_hot($hotid,$brand,$common)
|
|
|
{
|
|
|
$this->mHotBrand->add($hotid,$brand);
|
|
@@ -112,14 +155,14 @@ class category_dict extends words
|
|
|
}
|
|
|
|
|
|
public function hotid($gc_id) {
|
|
|
- return $this->gc_hot->get($gc_id);
|
|
|
+ return $this->mGcHot->get($gc_id);
|
|
|
}
|
|
|
|
|
|
private function add_gc_hot($gc_ids,$hot_id)
|
|
|
{
|
|
|
foreach ($gc_ids as $cid) {
|
|
|
$cid = intval($cid);
|
|
|
- $this->gc_hot->add($cid,$hot_id);
|
|
|
+ $this->mGcHot->add($cid,$hot_id);
|
|
|
}
|
|
|
}
|
|
|
}
|