Ejemplo n.º 1
0
 public function getProinfo($pidArr, $type = 1)
 {
     $proArr = $brandidArr = array();
     $profields = array('pid', 'proname', 'picurl', 'cid', 'pricetype', 'siteprice', 'minprice', 'maxprice', 'brand', 'brandname', 'brandlogo', 'cate1', 'cate2', 'cate3');
     $cacheProduct = new CacheProduct();
     $proArr = $cacheProduct->getSpecialpro($pidArr, $profields);
     $brandidArr = array_unique(array_column($proArr, 'brand'));
     $brandidStr = implode(',', $brandidArr);
     $brandArr = OpBrand::find(array('conditions' => 'brandid IN (' . $brandidStr . ') and state = 1', 'columns' => ' * '));
     if (!empty($brandArr)) {
         $brandArr = $brandArr->toArray();
     }
     foreach ($brandArr as $key => &$value) {
         $provinceArr = Area::getProvince($value['province']);
         $cityArr = Area::getCity($value['city']);
         $value['province_format'] = !empty($provinceArr) ? $provinceArr['areaname'] : '';
         $value['city_format'] = !empty($cityArr) ? $cityArr['areaname'] : '';
         $brand[$value['brandid']] = $value;
     }
     foreach ($proArr as $key => $value) {
         $tmp['proname'] = $value['proname'];
         $tmp['picurl'] = $value['picurl'][0];
         $tmp['prourl'] = \Xz\Func\UrlHelper::proLinkCre($value['pid'], $value['cate2'], $value['cate3'], $type);
         $tmp['brand'] = $value['brand'];
         $tmp['brandname'] = $value['brandname'];
         $tmp['brandlogo'] = $value['brandlogo'];
         $tmp['siteprice'] = $value['siteprice'];
         $tmp['maxprice'] = $value['maxprice'];
         $tmp['minprice'] = $value['minprice'];
         $tmp['pricetype'] = $value['pricetype'];
         $tmp['cate2'] = $value['cate2'];
         if (isset($brand[$value['brand']])) {
             $tmp['province_format'] = $brand[$value['brand']]['province_format'];
             $tmp['city_format'] = $brand[$value['brand']]['city_format'];
             $tmp['brandaddtime'] = $brand[$value['brand']]['addtime'];
         }
         $retArr[] = $tmp;
     }
     return $retArr;
 }
Ejemplo n.º 2
0
 /**
  * 获得一组商品的链接 支持普通和特权混合  超过30个就不支持了
  * @param  array $data 要查询的商品  结构是 array(pid,pid,pid,pid,)
  */
 public function getGoodsLink($data, $is_img = 0)
 {
     $data = $this->di['filter']->sanitize($data, 'string', '');
     if (empty($data) or !is_array($data) or count($data) > 50) {
         return $this->outputData(false, 600, '商品信息获取失败');
     }
     $data = array_unique($data);
     $goods = $special = '';
     foreach ($data as $v) {
         if ($v >= 900000000) {
             $special[] = $v;
         } else {
             $goods[] = $v;
         }
     }
     $rs1 = $rs0 = $link = array();
     if (is_array($special)) {
         $special = implode(',', $special);
         $rs0 = Pdspecialpro::find(array('pid in (' . $special . ')', "bind" => array(), 'columns' => 'pid,cate2,cate3,state,picurl'))->toArray();
     }
     if (is_array($goods)) {
         foreach ($goods as $k => $v) {
             $rs = Pdinfo::findFirst(array('pid = :pid:', "bind" => array('pid' => $v), 'columns' => 'pid,cate2,cate3,state,picurl'));
             if ($rs != false) {
                 $rs1[] = array('pid' => $rs->pid, 'cate2' => $rs->cate2, 'cate3' => $rs->cate3, 'state' => $rs->state, 'picurl' => $rs->picurl);
             }
         }
     }
     $info = array_merge($rs0, $rs1);
     foreach ($info as $value) {
         if ($is_img == 1) {
             $link[$value['pid']]['link'] = \Xz\Func\UrlHelper::proLinkCre($value['pid'], $value['cate2'], $value['cate3']);
             $picurlArr = json_decode($value['picurl'], true);
             $link[$value['pid']]['picurl'] = $picurlArr[0];
             $link[$value['pid']]['picurlarr'] = $picurlArr;
         } else {
             $link[$value['pid']] = \Xz\Func\UrlHelper::proLinkCre($value['pid'], $value['cate2'], $value['cate3']);
         }
     }
     return $this->outputData($link);
 }
Ejemplo n.º 3
0
 public function getProinfo($pidArr, $type = 1)
 {
     $proArr = $retArr = array();
     $profields = array('pid', 'proname', 'picurl', 'cid', 'pricetype', 'siteprice', 'minprice', 'maxprice', 'brand', 'brandname', 'brandlogo', 'cate1', 'cate2', 'cate3', 'is_op');
     $cacheProduct = new CacheProduct();
     $proArr = $cacheProduct->getSpecialpro($pidArr, $profields);
     foreach ($proArr as $key => $value) {
         $tmp['proname'] = $value['proname'];
         $tmp['picurl'] = $value['picurl'][0];
         $tmp['prourl'] = \Xz\Func\UrlHelper::proLinkCre($value['pid'], $value['cate2'], $value['cate3'], $type);
         $tmp['brand'] = $value['brandname'];
         $tmp['siteprice'] = $value['siteprice'];
         $tmp['maxprice'] = $value['maxprice'];
         $tmp['minprice'] = $value['minprice'];
         $tmp['pricetype'] = $value['pricetype'];
         $tmp['cate2'] = $value['cate2'];
         $tmp['brandid'] = $value['brand'];
         $tmp['brandlogo'] = $value['brandlogo'];
         $tmp['is_op'] = $value['is_op'];
         $retArr[] = $tmp;
     }
     return $retArr;
 }
Ejemplo n.º 4
0
 /**
  * 商品搜索
  * @param  array   $where  条件
  * @param  string  $column 要显示的字段
  * @param  string  $wd     要搜索的关键词
  * @param  integer $offset 分页
  * @param  integer $limit  分页
  * @param  integer $type   1是主表  2是审核表
  * @param  string $order   排序
  * @param  integer $is_op  默认为不是op   0不是op   1是op  主要用来调取不同的企业接口
  */
 public function search($where = array(), $column = "pid,cid,supid,proname,pricetype,minprice,maxprice,siteprice,addtime,uptime,star,cate2,cate3,unit,picurl,is_op", $wd = '', $offset = 0, $limit = 20, $type = 1, $order = 'uptime DESC', $is_op = 0, $islike = 0)
 {
     $condition = '1';
     $bind = array();
     $wd = trim($wd);
     $offset = $this->di['filter']->sanitize($offset, 'int', 0);
     $limit = $this->di['filter']->sanitize($limit, 'int', 20);
     if (!isset($where['supid'])) {
         $condition .= ' and supid > 0';
     }
     if (is_array($where)) {
         foreach ($where as $key => $value) {
             if (is_array($value)) {
                 $value = $this->di['filter']->sanitize($value, "string", '');
                 $condition .= ' and ' . $key . ' in(' . implode(',', $value) . ')';
             } else {
                 $value = $this->di['filter']->sanitize($value, "string", 0);
                 $condition .= ' and ' . $key . '=:' . $key . ':';
                 $bind[$key] = $value;
             }
         }
     }
     if (!isset($where['state'])) {
         if ($type == 1) {
             $condition .= ' and state in(1,-2,-3)';
         } else {
             $condition .= ' and state in(0,-1)';
         }
     }
     if (!empty($wd)) {
         $wd = $this->di['filter']->sanitize($wd, "string", '');
         $condition .= ' and proname like "%' . $wd . '%"';
     }
     if ($type == 1) {
         $goods = Pdspecialpro::find(array($condition, "bind" => $bind, 'columns' => $column, 'order' => $order, 'offset' => $offset, 'limit' => $limit))->toArray();
         $count = Pdspecialpro::count(array($condition, "bind" => $bind));
     } elseif ($type == 2) {
         $goods = Mspecialpro::find(array($condition, 'bind' => $bind, 'columns' => $column, 'order' => $order, 'offset' => $offset, 'limit' => $limit))->toArray();
         $count = Mspecialpro::count(array($condition, "bind" => $bind));
     }
     if (!empty($goods) && is_array($goods)) {
         foreach ($goods as $v) {
             $supidArr[] = $v['supid'];
         }
         $comlist = array();
         if (isset($supidArr) && is_array($supidArr) && !empty($supidArr)) {
             if ($is_op == 1) {
                 //这个只能运营商才能用的企业接口, 查的是供应商和运营商关系表,
                 $com = OpSupService::getInstance()->getBysupid($supidArr);
             } else {
                 //这个接口才是查的company表
                 $com = ComService::getInstance()->getListBySups($supidArr);
             }
             if ($com['code'] && !empty($com['data']) && is_array($com['data'])) {
                 foreach ($com['data'] as $v2) {
                     $comlist[$v2['supid']] = $v2;
                 }
             }
             foreach ($goods as $k1 => $v1) {
                 if (isset($comlist[$v1['supid']])) {
                     $goods[$k1]['comname'] = $comlist[$v1['supid']]['comname'];
                     if ($is_op == 1) {
                         $goods[$k1]['opuserid'] = $comlist[$v1['supid']]['opuserid'];
                         $goods[$k1]['opuser'] = $comlist[$v1['supid']]['opuser'];
                     }
                 }
             }
         }
         if ($islike == 1) {
             foreach ($goods as $k2 => $v2) {
                 if (isset($v2['pid']) && isset($v2['cate2']) && isset($v2['cate3'])) {
                     $url = \Xz\Func\UrlHelper::proLinkCre($v2['pid'], $v2['cate2'], $v2['cate3']);
                 }
                 if (!empty($url)) {
                     $goods[$k2]['link'] = $url;
                 }
             }
         }
         $goods['count'] = $count;
         return $this->outputData($goods);
     } else {
         $goods['count'] = 0;
         return $this->outputData($goods);
     }
 }