Exemple #1
0
 /**
  * 特权商品数量
  * @param  int  $cid   供应商cid
  * @param  int  $is_op   1为状态0  2为状态1
  * @param  int $state   状态
  */
 public function getSpecialCount($cid = 0, $is_op = 0, $state = 100, $offset = 0, $limit = 20, $type = 1, $order = 'uptime desc')
 {
     $cid = $this->di['filter']->sanitize($cid, 'int', 0);
     $type = $this->di['filter']->sanitize($type, 'int', 0);
     $is_op = $this->di['filter']->sanitize($is_op, 'int', 0);
     $state = $this->di['filter']->sanitize($state, 'int', '0');
     if ($is_op == 1) {
         $is_op = 0;
     } elseif ($is_op == 2) {
         $is_op = 1;
     }
     $condition = 1;
     if (!empty($cid)) {
         $condition .= ' and cid = :cid:';
         $bind['cid'] = $cid;
     }
     if ($state == 100) {
         $condition .= ' and state !=0';
     } else {
         $condition .= ' and state =:state:';
         $bind['state'] = $state;
     }
     $condition .= ' and is_op=:is_op:';
     $bind['is_op'] = $is_op;
     if ($type == 1) {
         $count = Mspecialpro::count(array($condition, 'bind' => $bind));
         return $this->outputData($count);
     } elseif ($type == 2) {
         $data = Mspecialpro::find(array($condition, 'bind' => $bind, 'limit' => $limit, 'offset' => $offset, 'order' => $order))->toArray();
         $data['count'] = Mspecialpro::count(array($condition, 'bind' => $bind));
         return $this->outputData($data);
     }
 }
 /**
  * 获得一组特权商品的信息
  * @param  array $pid 商品id数组
  * @param  int $type 1是正式表 2是M表
  * @param  string $column 要显示的字段  默认为全部
  */
 public function getSpecialAndComAll($pids, $type = 1, $column = '*')
 {
     $pids = $this->di['filter']->sanitize($pids, 'string', '');
     $column = $this->di['filter']->sanitize($column, 'string', '');
     $type = $this->di['filter']->sanitize($type, 'int', 0);
     if (empty($pids) or !is_array($pids) or empty($column)) {
         return $this->outputData(false, 600, '参数错误');
     }
     $rs = $goods = array();
     if ($type == 1) {
         $pids = implode(',', $pids);
         $rs = Pdspecialpro::find(array('pid in (' . $pids . ') and state in (1,-2,-3)', "bind" => array(), 'columns' => $column))->toArray();
     } elseif ($type == 2) {
         $pids = implode(',', $pids);
         $rs = Mspecialpro::find(array('id in (' . $pids . ') and state in (0,-1)', "bind" => array(), 'columns' => $column))->toArray();
     }
     if (!empty($rs) and is_array($rs)) {
         foreach ($rs as $v) {
             $supidArr[] = $v['supid'];
             if ($type == 1) {
                 $goods[$v['pid']] = $v;
             } elseif ($type == 2) {
                 $goods[$v['id']] = $v;
             }
         }
     }
     return $this->outputData($goods);
 }