/** * 特权商品数量 * @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 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); }