/** * 特权商品列表 * @param int $cid 供应商cid * @param int $is_op 1为状态0 2为状态1 * @param int $state 状态 * @param int $offset 分页起始值 * @param int $limit 分页条数 * @param string $order 排序 */ public function getList($cid = 0, $is_op = 0, $state = 1, $offset = 0, $limit = 20, $order = 'pid desc') { $offset = $this->di['filter']->sanitize($offset, 'int', 0); $limit = $this->di['filter']->sanitize($limit, 'int', 20); $cid = $this->di['filter']->sanitize($cid, '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; } if (empty($supid)) { $condition = 'state=:state:'; $bind['state'] = $state; } else { $condition = 'cid = :cid: and state=:state:'; $bind['state'] = $state; $bind['cid'] = $cid; } if (!empty($is_op)) { $condition .= ' and is_op=:is_op:'; $bind['is_op'] = $is_op; } if (array_search($state, array(1 => 1, 2 => -3, 3 => -2), false) != false) { $data = Pdspecialpro::find(array($condition, 'bind' => $bind, 'limit' => $limit, 'offset' => $offset, 'order' => $order))->toArray(); $data['count'] = Pdspecialpro::count(array($condition, 'bind' => $bind)); } else { $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 string $condition 条件 * @param integer $type 选择数据表 默认1为正式表 2为M表 * @param array $bind 条件 * @return int 条数 */ public function productNum($condition, $type = 1, $bind = array()) { if (empty($condition)) { return $this->outputData(0); } if ($type == 1) { $count = \Gcproinfo\Models\Pdinfo::count(array($condition, "bind" => $bind)); } elseif ($type == 2) { $count = \Gcproinfo\Models\Mproduct::count(array($condition, "bind" => $bind)); } elseif ($type == 3) { $count = \Gcproinfo\Models\Pdoptimize::count(array($condition, "bind" => $bind)); } elseif ($type == 4) { $count = \Gcproinfo\Models\Pdspecialpro::count(array($condition, "bind" => $bind)); } elseif ($type == 5) { $count = \Gcproinfo\Models\Mspecialpro::count(array($condition, "bind" => $bind)); } return $this->outputData($count); }
/** * 统计普通特权商品数量 发特权产品限制使用 * @param string $condition 条件 * @param array $bind 条件 * @return int 条数 */ public function ordinarySpecialNum($cid) { if (empty($cid) || !is_numeric($cid)) { return $this->outputData(0); } $count1 = Pdspecialpro::count(array('cid=:cid: and state in (1,-2,-3) and is_op=0', "bind" => array('cid' => $cid))); $count2 = Mspecialpro::count(array('cid=:cid: and state in (0,-1) and is_op=0', "bind" => array('cid' => $cid))); return $this->outputData($count1 + $count2); }