public function get()
 {
     $order = $_REQUEST['order'];
     $seq = $_REQUEST['seq'];
     $page = (int) $_REQUEST['page'];
     $page_size = $_REQUEST['page_size'] ? $_REQUEST['page_size'] : 20;
     $keyword = trim($_REQUEST['keyword']);
     $service = new CompetitorAd();
     $list = $service->get_competitor_ads_stat($order, $seq, $keyword);
     $total = count($list);
     $list = array_slice($list, $page * $page_size, $page_size);
     $this->output(array('code' => 0, 'msg' => 'ok', 'list' => $list, 'total' => $total));
 }
 public function update(array $attr = null)
 {
     $ad_service = new CompetitorAd();
     $me = $_SESSION['id'];
     if (!$ad_service->check_delivery_ad_owner($this->id, $me)) {
         throw new Exception('不是您对接的广告,您不能修改', 100);
     }
     //拆分不同表的数据
     if ($attr['status']) {
         $attr['status_editor'] = $me;
         $attr['status_time'] = date("Y-m-d H:i:s");
     }
     $delivery = Utils::array_pick($attr, self::$FIELDS_DELIVERY);
     //更新广告信息
     $DB_write = $this->get_write_pdo();
     $check = SQLHelper::insert_update($DB_write, self::$T_DELIVERY, $delivery, array('pack_name' => $this->id));
     if (!$check) {
         throw new Exception('修改失败', 101);
     }
     $this->attributes = $attr;
     return $attr;
 }