示例#1
0
 /**
  * 获得采集商品列表
  * @param  int  $cid    企业id
  * @param  string  $groupid    分组字符串
  * @param  int $offset 分页起始值
  * @param  int $limit  分页
  * @param  string $column  字段  默认为全部
  * @param  string  $order  排序
  */
 public function getCaijiProductList($cid, $groupid = 0, $offset = 0, $limit = 20, $column = '*', $order = ' uptime desc')
 {
     $cid = $this->di['filter']->sanitize($cid, 'int', 0);
     $groupid = $this->di['filter']->sanitize($groupid, 'string', 0);
     $offset = $this->di['filter']->sanitize($offset, 'int', 0);
     $limit = $this->di['filter']->sanitize($limit, 'int', 20);
     if (!empty($groupid)) {
         $pidgid = explode('-', $groupid);
         $gid = isset($pidgid[0]) ? $pidgid[0] : 0;
         $cgid = isset($pidgid[1]) ? $pidgid[1] : 0;
         $condition = 'cid = :cid: and gid=:gid: and cgid=:cgid: and state = 1';
         $bind = array('cid' => $cid, 'gid' => $gid, 'cgid' => $cgid);
         $pidgid = CaijiPdPidgid::find(array($condition, 'bind' => $bind, 'order' => 'pid DESC', 'limit' => $limit, 'offset' => $offset));
         $pidArr = array();
         if (is_object($pidgid)) {
             $pidgid = $pidgid->toArray();
             foreach ($pidgid as $v) {
                 if (isset($v['pid'])) {
                     $pidArr[] = $v['pid'];
                 }
             }
             if (is_array($pidArr)) {
                 $pidArr = implode(',', $pidArr);
             }
             if (!empty($pidArr)) {
                 $data = CaijiPdInfo::find(array('cid = :cid: and pid in (' . $pidArr . ')', 'bind' => array('cid' => $cid), 'columns' => $column));
                 if ($data) {
                     $data = $data->toArray();
                 } else {
                     $data = array();
                 }
             }
         }
         $data['count'] = CaijiPdPidgid::count(array($condition, 'bind' => $bind));
     } else {
         $condition = 'cid = :cid: and state = 1';
         $bind = array('cid' => $cid);
         $data = CaijiPdinfo::find(array($condition, 'bind' => $bind, 'limit' => $limit, 'offset' => $offset, 'order' => $order, 'columns' => $column));
         if ($data) {
             $data = $data->toArray();
         } else {
             $data = array();
         }
         $data['count'] = CaijiPdinfo::count(array($condition, 'bind' => $bind));
     }
     return $data;
 }
示例#2
0
 /**
  * [productByPids description]
  * @param  array  $pids [description]
  * @return [type]       [description]
  */
 public function productByPids($pids = array())
 {
     if (empty($pids)) {
         return $this->outputData(false, 600, '产品PID数组为空');
     }
     $cjpids = array();
     $normalpids = array();
     $specialpids = array();
     foreach ($pids as $k => $v) {
         $pid = intval($v);
         if (empty($pid)) {
             continue;
         }
         if ($pid >= 900000000) {
             $specialpids[] = $pid;
         } elseif ($pid >= 500000000 && $pid < 900000000) {
             $cjpids[] = $pid;
         } else {
             $normalpids[] = $pid;
         }
     }
     $normalpids = array_unique($normalpids);
     $specialpids = array_unique($specialpids);
     $cjpids = array_unique($cjpids);
     $proInfo = array();
     if (!empty($normalpids)) {
         $proInfoObj = Pdinfo::find(array('conditions' => "pid in (" . implode(',', $normalpids) . ")"));
         if (is_object($proInfoObj)) {
             $proInfo = $proInfoObj->toArray();
         }
     }
     $spProInfo = array();
     if (!empty($specialpids)) {
         $spProInfoObj = Pdspecialpro::find(array('conditions' => "pid in (" . implode(',', $specialpids) . ")"));
         if (is_object($spProInfoObj)) {
             $spProInfo = $spProInfoObj->toArray();
         }
     }
     $cjProInfo = array();
     if (!empty($cjpids)) {
         $cjProInfoObj = CaijiPdinfo::find(array('conditions' => "pid in (" . implode(',', $cjpids) . ")"));
         if (is_object($cjProInfoObj)) {
             $cjProInfo = $cjProInfoObj->toArray();
         }
     }
     $result = array();
     $result = array_merge($result, $proInfo);
     $result = array_merge($result, $cjProInfo);
     $result = array_merge($result, $spProInfo);
     $result = ArrayHelper::convertPrimary($result, 'pid');
     return $this->outputData($result);
 }