示例#1
0
 /**
  * 开始遍历产品信息
  * @param type $cid
  */
 public function proAction($cid)
 {
     echo $cid;
     echo "\n";
     $pid = 0;
     while (1) {
         $proMysql = Pdinfo::find(array("conditions" => "pid > ?1 and cid = ?2", "bind" => array(1 => $pid, 2 => $cid), "columns" => "pid, proname, state", "limit" => 100, "order" => "pid asc"));
         $proMysqlRs = $proMysql->toArray();
         if (empty($proMysqlRs)) {
             echo "=================cid=" . $cid . "的企业的所有产品都已经打入队列处理===============\n";
             return true;
         }
         foreach ($proMysqlRs as $value) {
             $pid = $value["pid"];
             if ($value["state"] != 1) {
                 echo "============" . $pid . "产品状态不正常=============\n";
                 continue;
             }
             $this->writeRabbit($pid, $cid);
         }
     }
 }
示例#2
0
 /**
  * 获得一组商品和企业的信息
  * @param  array $data 要查询的商品  结构是 array('pid'=>'cid','pid'=>'cid')
  * @param  string $column 要显示的字段  默认为全部
  */
 public function getComGoodsbyid($data, $column = '*')
 {
     $data = $this->di['filter']->sanitize($data, 'string', '');
     $column = $this->di['filter']->sanitize($column, 'string', '');
     if (empty($data) or !is_array($data) or empty($column)) {
         return $this->outputData(false, 600, '商品信息获取失败');
     }
     $goods = $special = $cidArr = '';
     foreach ($data as $k => $v) {
         if ($k >= 900000000) {
             $special[] = $k;
         } else {
             $goods[] = $k;
             $cidArr[] = $v;
         }
     }
     $rs1 = $rs2 = array();
     if (is_array($special)) {
         $special = implode(',', $special);
         $rs1 = Pdspecialpro::find(array('pid in (' . $special . ') and state in (1,-2,-3)', "bind" => array(), 'columns' => $column))->toArray();
     }
     if (is_array($goods) and is_array($cidArr)) {
         $goods = implode(',', $goods);
         $cid = implode(',', $cidArr);
         $rs2 = Pdinfo::find(array('cid in (' . $cid . ') and pid in (' . $goods . ') and state in(0,1,-1,-2)', "bind" => array(), 'columns' => $column))->toArray();
     }
     $rs1 = array_merge($rs1, $rs2);
     if (is_array($rs1)) {
         $supidArr = array();
         foreach ($rs1 as $v) {
             $supidArr[] = $v['supid'];
         }
         $comlist = array();
         if (is_array($supidArr) and !empty($supidArr)) {
             $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 ($rs1 as $k1 => $v1) {
             if (isset($comlist[$v1['supid']])) {
                 $rs1[$k1]['comname'] = $comlist[$v1['supid']]['comname'];
             }
         }
         return $this->outputData($rs1);
     } else {
         return $this->outputData(false, 600, '商品信息获取失败');
     }
 }
示例#3
0
 /**
  * 获取普通产品列表
  * @param  array   $where  条件
  * @param  string  $column 字段
  * @param  integer $offset 分页
  * @param  integer $limit  分页
  * @param  integer $type   1为正式表  2为m表
  * @param  string  $order  排序
  */
 public function commonList($where = array(), $column = "*", $offset = 0, $limit = 20, $type = 1, $order = 'uptime DESC')
 {
     $condition = '1';
     $bind = array();
     $offset = $this->di['filter']->sanitize($offset, 'int', 0);
     $limit = $this->di['filter']->sanitize($limit, 'int', 20);
     if (is_array($where)) {
         if (!array_key_exists('cid', $where)) {
             return $this->outputData(false, 600, '暂无数据');
         }
         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 (0,1,-1,-2)';
         } else {
             $condition .= ' and state = -1';
         }
     }
     $goods = array();
     if ($type == 1) {
         $goods = \Gcproinfo\Models\Pdinfo::find(array($condition, "bind" => $bind, 'columns' => $column, 'order' => $order, 'offset' => $offset, 'limit' => $limit))->toArray();
         $count = \Gcproinfo\Models\Pdinfo::count(array($condition, "bind" => $bind));
     } else {
         $goods = \Gcproinfo\Models\Mproduct::find(array($condition, "bind" => $bind, 'columns' => $column, 'order' => $order, 'offset' => $offset, 'limit' => $limit))->toArray();
         $count = \Gcproinfo\Models\Mproduct::count(array($condition, "bind" => $bind));
     }
     $goods['count'] = $count;
     return $this->outputData($goods);
 }
示例#4
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);
 }