Example #1
0
 public static function get($cate3)
 {
     //return 1002;
     $cate3 = (int) $cate3;
     //$cate3Arr = self::$cate3Arr;
     $cate3Arr = \Xz\Lib\Cate3chart::$config;
     $cate3Str = Gcwqconf::getConf('/qconf/chart/cate3arr', APP_ENV);
     $cate3Arr = json_decode($cate3Str, true);
     if (empty($cate3Arr)) {
         $id = 1002;
         return $id;
     }
     if (!empty($cate3)) {
         $cateRs = \Xz\Lib\Cate::getCateInfo(array($cate3), array('nav'));
         $nav = $cateRs[$cate3]['nav'];
         //是否一级买断
         if (isset($cate3Arr[$nav[0]['cateid']])) {
             $id = $cate3Arr[$nav[0]['cateid']];
         } elseif (isset($cate3Arr[$nav[1]['cateid']])) {
             //二级买断
             $id = $cate3Arr[$nav[1]['cateid']];
         } elseif (isset($cate3Arr[$cate3])) {
             $id = $cate3Arr[$cate3];
         } else {
             $id = 1002;
         }
     } else {
         $id = 1002;
     }
     return $id;
 }
 /**
  * 新的获取cate3方案
  *
  * @Author   tianyunzi
  * @DateTime 2016-01-04T16:00:41+0800
  * @param    [type]                   $keyword [description]
  * @return   [type]                            [description]
  */
 public function getCate3NN($keyword)
 {
     $relaFirst = array_slice($this->relaArr, 0, 1, true);
     $cateid = key($relaFirst);
     /* 查询下所有的分类信息 */
     $cateidArr = array_keys($this->relaArr);
     $cateInfoArr = \Xz\Lib\Cate::getCateInfo($cateidArr, array("info"));
     foreach ($cateInfoArr as $key => $value) {
         if ($value["info"]["catename"] == $keyword) {
             return $key;
         }
         if (strstr($value["info"]["catename"], $keyword)) {
             $cateid = $key;
             break;
         }
     }
     return $cateid;
 }
Example #3
0
 /**
  * 保存int1页信息
  * @author francis
  * @return array
  */
 public function saveInit1($save)
 {
     //取得分类是否是特殊行业
     $cate = \Xz\Lib\Cate::getCateInfo(array($save['info']['cate2']), array('info'));
     $isSpecial = $cate[$save['info']['cate2']]['info']["is_special"];
     $save['info']['is_complete'] = 0;
     //普通行业
     if ($isSpecial == 0) {
         $save['info']['is_complete'] = 1;
         //完善企业信息
         //是否发产品
         $infoFirst = InfoService::getInstance()->isFirst($save['info']['cid']);
         if ($infoFirst['data'] >= 1) {
             //已发+以完善
             //激活商铺
             $save['info']['state'] = 1;
         } else {
             //更新企业状态为-3(未发+已完善)
             $save['info']['state'] = -3;
         }
     }
     $supid = $save['info']['supid'];
     $comObj = \Gccominfo\Models\GcCompany::findFirst(array("supid=:supid:", 'bind' => array('supid' => $supid)));
     $r1 = $comObj->save($save['info']);
     $comDataObj = \Gccominfo\Models\GcComData::findFirst(array("cid=:cid:", 'bind' => array('cid' => $comObj->cid)));
     $default = array();
     if (!is_object($comDataObj)) {
         $comDataObj = new \Gccominfo\Models\GcComData();
         $default = $this->comDataStruct;
     }
     $r2 = $comDataObj->save(array_merge($default, $save['data']));
     return $this->outputData(array('is_complete' => $save['info']['is_complete'], $r1, $r2));
 }
Example #4
0
 /**
  * 从sphinx获取数据
  * @author 刘建辉
  * @datetime 2015-08-19T18:05:19+0800
  * @return   [type]                   [description]
  */
 public function getDataFromSpinx($data)
 {
     $this->data = $data;
     if (isset($this->data['redword']) && !empty($this->data['redword'])) {
         $this->data['split'] = $this->data['redword'];
     } else {
         //分词
         $this->data['split'] = $this->data['wd'];
         $splitWd = \Xz\Func\Common\Tools::curlGetContentMs($this->di['config']->base->split . '/wd/' . urlencode($this->data['wd']), 50);
         if ($splitWd) {
             $this->data['split'] = $splitWd;
         }
     }
     $sphinxConfig = $this->di["config"]["prosearchsphinx"];
     $conn = new Connection();
     //$indexTable = "product_distri";
     $indexTable = "product_m_distri";
     //TODO 索引范围
     if (!isset($this->data['cateid'])) {
         if (isset($this->data['cate3'])) {
             $this->data['cateid'] = $this->data['cate3'];
         }
     }
     //逻辑判断必须加>0
     if (isset($this->data['cateid']) && $this->data['cateid'] > 0) {
         $cateinfo = \Xz\Lib\Cate::getCateInfo(array($this->data['cateid']), array('nav'));
         if (!empty($cateinfo)) {
             $this->data['cate1'] = $cateinfo[$this->data['cateid']]['nav'][0]['cateid'];
             $indexTable = "product_distri" . '_' . $this->data['cate1'];
         }
         //$indexTable = "product_distri";
     }
     $conn->setParams(array('host' => $sphinxConfig->host, 'port' => $sphinxConfig->port));
     $gcdweight = "weight()+IF(id>900000000, tradenum*100, 0)+inquirynum*20+star*2+basescore*5+creditscore+IF(is_op=1, all_uv*10+all_pv, 0)+IF(id>900000000, weight()*0.1, 0) as gcpdweight";
     //$gcdweight = "weight() + gcdweight as gcpdweight";
     $query = SphinxQL::create($conn)->select('id', 'cid', $gcdweight)->from($indexTable);
     $query->match('*', $this->data['split']);
     $query->option('max_matches', 200);
     if (!empty($this->data['cateid']) && intval($this->data['cateid']) > 0) {
         $query->where('cate3', '=', intval($this->data['cateid']));
     }
     if (!empty($this->data['brand']) && intval($this->data['brand']) > 0) {
         $query->where('brand', '=', intval($this->data['brand']));
     }
     if (!empty($this->data['province']) && intval($this->data['province']) > 0) {
         $query->where('province', '=', intval($this->data['province']));
     }
     if (!empty($this->data['city']) && intval($this->data['city']) > 0) {
         $query->where('city', '=', intval($this->data['city']));
     }
     if (!empty($this->data['iscertify']) && intval($this->data['iscertify']) > 0) {
         $query->where('is_gccertify', '=', intval($this->data['iscertify']));
     }
     if (!empty($this->data['isprice']) && intval($this->data['isprice']) > 0) {
         $query->where('price', '>', 0);
     }
     if (!empty($this->data['feature'])) {
         $featureArr = explode('_', $this->data['feature']);
         foreach ($featureArr as $value) {
             $query->where('feature', '=', intval($value));
         }
     }
     if (!empty($this->data['sort'])) {
         switch ($this->data['sort']) {
             case 1:
                 $query->orderBy('tradenum', 'DESC');
                 //销量
                 break;
             case 2:
                 $query->orderBy('visitnum', 'DESC');
                 //访问量/热度
                 break;
             case 3:
                 $query->orderBy("price", "DESC");
                 break;
             case 4:
                 $query->orderBy("price", "ASC");
                 break;
             case 6:
                 $query->orderBy("integral", "ASC");
                 break;
             default:
                 $query->orderBy("gcpdweight", "DESC");
                 break;
         }
     } else {
         $query->orderBy("gcpdweight", "DESC");
     }
     //$facet = Facet::create($conn)->facet('cate3');
     //$query->facet($facet);
     $facet = Facet::create($conn)->facet('feature')->limit(20)->orderby("count(*)", "desc");
     $query->facet($facet);
     //品牌
     $brand = Facet::create($conn)->facet('brand')->limit(20)->orderby("count(*)", "desc");
     $query->facet($brand);
     if (!empty($this->data['province'])) {
         //市
         $facet = Facet::create($conn)->facet('city')->limit(20)->orderby("count(*)", "desc");
         $query->facet($facet);
     } else {
         //省
         $facet = Facet::create($conn)->facet('province')->limit(20)->orderby("count(*)", "desc");
         $query->facet($facet);
     }
     //查询条数
     //$query->limit($this->data['offset'], $this->data['limit']);
     $query->limit(0, 200);
     //匹配设定
     $query->option('field_weights', array('proname' => 300));
     //$query->option('ranker', 'sph04');
     $batchResult = $query->executeBatch();
     $result = array();
     if (is_array($batchResult) && count($batchResult) > 0) {
         $result['data'] = $batchResult[0];
         //$result['cate3'] = isset($batchResult[1]) ? $batchResult[1] : array();
         $result['property'] = isset($batchResult[1]) ? $batchResult[1] : array();
         $result['brand'] = isset($batchResult[2]) ? $batchResult[2] : array();
         if (!empty($this->data['province'])) {
             $result['city'] = isset($batchResult[3]) ? $batchResult[3] : array();
         } else {
             $result['province'] = isset($batchResult[3]) ? $batchResult[3] : array();
         }
     }
     //if (!empty($result['data'])) {
     foreach ($result['data'] as $key => &$value) {
         //拿到产品ID,企业ID
         $value = array($value['id'], $value['cid']);
     }
     unset($value);
     //防霸屏
     $result['data'] = $this->sortData($result['data']);
     /*if (!empty($result['cate3'])) {
       $result['cate3'] = json_encode(array_combine(array_column($result['cate3'], 'cate3'), array_column($result['cate3'], 'count(*)')));
       } else {
       $result['cate3'] = '[]';
       }*/
     if (!empty($result['province'])) {
         $result['province'] = json_encode(array_combine(array_column($result['province'], 'province'), array_column($result['province'], 'count(*)')));
     } else {
         $result['province'] = '[]';
     }
     if (!empty($result['city'])) {
         $result['city'] = json_encode(array_combine(array_column($result['city'], 'city'), array_column($result['city'], 'count(*)')));
     } else {
         $result['city'] = '[]';
     }
     if (!empty($result['brand'])) {
         $result['brand'] = json_encode(array_combine(array_column($result['brand'], 'brand'), array_column($result['brand'], 'count(*)')));
     } else {
         $result['brand'] = '[]';
     }
     if (!empty($result['property'])) {
         $result['property'] = json_encode(array_combine(array_column($result['property'], 'feature'), array_column($result['property'], 'count(*)')));
     } else {
         $result['property'] = '[]';
     }
     //}
     //重新实例化以获取查询到的总数
     $sphinxql = new SphinxQL($conn);
     $total = $sphinxql->query('show meta');
     $total = $this->formatSphQLArray($total->execute());
     $result['total_found'] = $total['total_found'];
     $result['time'] = $total['time'];
     $result['split'] = $this->data['split'];
     return $result;
 }
Example #5
0
 public static function getShow($cate = array(), $property = array())
 {
     if (!is_array($cate) || !is_array($property) || empty($cate) || empty($property)) {
         return array();
     }
     if ($cate['cate3'] != 0) {
         $docate = intval($cate['cate3']);
     } elseif ($cate['cate2'] != 0) {
         $docate = intval($cate['cate2']);
     }
     if ($docate == 0) {
         return array();
     }
     $propertyArr = $propertyShowArr = array();
     $propertyArr = Cate::getAttr($docate);
     foreach ($propertyArr as $key => $value) {
         $doProperty[$value['fid']] = $value;
     }
     $show = array();
     foreach ($property as $dokey => $value) {
         if (!isset($doProperty[$dokey])) {
             continue;
         }
         $myval = '';
         $opArr = $doProperty[$dokey];
         if ($opArr['showtype'] == 1 || $opArr['showtype'] == 3) {
             $show[$dokey] = $value;
         }
     }
     return $show;
 }