Esempio n. 1
0
 public function testMerge()
 {
     $adv = Advertise::model()->findByPk(23);
     $map = array();
     foreach ($adv->advChannels as $advChannel) {
         $map[$advChannel->tag] = $advChannel;
     }
 }
Esempio n. 2
0
 private function getAdvId($name)
 {
     $model = Advertise::model()->findByAttributes(array('name' => $name));
     if ($model) {
         return $model->id;
     }
     return 0;
 }
Esempio n. 3
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $user = Yii::app()->user;
     if (Yii::app()->request->isPostRequest) {
         $type = $_POST['type'];
         if ($type == 'login') {
             $identity = new UserIdentity($_POST['LoginForm']['email'], $_POST['LoginForm']['password']);
             if ($identity->authenticate()) {
                 $user->login($identity);
                 $this->redirect('/');
             } else {
             }
         }
         return;
     }
     // renders the view file 'protected/views/site/index.php'
     // using the default layout 'protected/views/layouts/main.php'
     if ($user->isGuest) {
         $this->render('login', array('userinput' => Yii::app()->request->isPostRequest ? $_POST['LoginForm'] : array()));
     } else {
         $criteria = new CDbCriteria();
         if ($user->isChannel()) {
             if ($user->getChannelId()) {
                 $criteria->compare('channel_id', Yii::app()->user->getChannelId());
             } else {
                 echo '此账户尚未开通,请联系管理员';
                 return;
             }
         } else {
             //管理员
             $channel_id = $user->getChannelId();
             if ($user->getChannelId()) {
                 $criteria->compare('channel_id', Yii::app()->user->getChannelId());
             }
         }
         //添加搜索条件
         if ($_GET) {
             $tag = $_GET['tag'];
             $adv_name = $_GET['adv_name'];
             $adv_id = "";
             if ($adv_name) {
                 $advertise = Advertise::model();
                 $adv_id = $advertise->getAdvId($adv_name);
             }
             $startTime = $_GET['startTime'];
             $endTime = $_GET['endTime'];
             $criteria->compare('tag', $tag);
             $criteria->compare('adv_id', $adv_id);
             if ($startTime) {
                 $criteria->addBetweenCondition('date', $startTime, $endTime);
             }
         }
         $criteria->order = "date desc";
         $dataProvider = new CActiveDataProvider('AdvData', array('criteria' => $criteria, 'pagination' => array('pageSize' => 20, 'pageVar' => 'page')));
         $this->render('index', array('attributes' => array('date', 'adv.name', 'tag', 'download_number', 'price', 'total_price', 'star_level'), 'current_channel_id' => $user->getChannelId(), 'channels' => Yii::app()->user->isAdmin() ? Channel::model()->findAll() : array(), 'dataProvider' => $dataProvider));
     }
 }
 /**
  * @return string
  *
  * 返回表的名字
  */
 public function getTableName()
 {
     $filters = $this->getFilterCondition();
     if (isset($filters['adv_id'])) {
         $model = Advertise::model()->findByPk($filters['adv_id']);
         if ($model) {
             return $model->cp->name . '-' . $model->name . ' 渠道列表';
         }
     }
     return '业务-渠道列表';
 }
Esempio n. 5
0
 public function actionUpload()
 {
     $filter = $this->getFilterCondition();
     if (isset($filter['adv_channel_id'])) {
         $advertiseChannel = AdvertiseChannel::model()->findByPk($filter['adv_channel_id']);
         $advertise = $advertiseChannel->advertise;
     } else {
         if (isset($filter['adv_id'])) {
             $advertise = Advertise::model()->findByPk($filter['adv_id']);
         }
     }
     //$historyList = $adv_data->getDayDataForIn('',$startTime, $endTime, false);
     $this->render('upload', array('filters' => $this->getFilterCondition(), 'advertise' => $advertise, 'adv_channel_id' => $filter['adv_channel_id']));
 }
Esempio n. 6
0
 public function getDailyToTalData($date)
 {
     /*
         $db = Yii::app()->db;
         $sql = "select advertise.name as adv_name,sum(total_price) as prices,sum(download_number) as downloads from adv_data join advertise on advertise.id = adv_id where date = :date group by adv_id";
         $command = $db->createCommand($sql);
         $command->bindParam(':date', $date);
         return $command->queryAll();
     */
     $criteria = new CDbCriteria();
     $criteria->compare('ctime', ">= {$date}");
     $criteria->order = 'date desc';
     $data = array();
     $advId2NameMap = array();
     foreach (Advertise::model()->findAll() as $adv) {
         $advId2NameMap[$adv->id] = $adv->name;
     }
     foreach ($this->findAll($criteria) as $model) {
         if (!isset($data[$model->date])) {
             $data[$model->date] = array();
         }
         if (!isset($data[$model->date][$model->adv_id])) {
             $data[$model->date][$model->adv_id] = array('adv_name' => $advId2NameMap[$model->adv_id], 'download_number' => 0, 'total_price' => 0);
         }
         $data[$model->date][$model->adv_id]['download_number'] += sprintf("%01.2f", floatval($model->download_number));
         $data[$model->date][$model->adv_id]['total_price'] += sprintf("%01.2f", floatval($model->total_price));
     }
     return $data;
 }
Esempio n. 7
0
 public function getTableName()
 {
     $filters = $this->getFilterCondition();
     $conditions = array();
     if (isset($filters['cp_id'])) {
         $model = CP::model()->findByPk($filters['cp_id']);
         if ($model) {
             $conditions[] = "CP:{$model->name}";
         }
     }
     if (isset($filters['adv_id'])) {
         $model = Advertise::model()->findByPk($filters['adv_id']);
         if ($model) {
             $conditions[] = "业务:{$model->name}";
         }
     }
     if (isset($filters['channel_id'])) {
         $model = Channel::model()->findByPk($filters['channel_id']);
         if ($model) {
             $conditions[] = "渠道:{$model->name}";
         }
     }
     /*2014-11-17包名*/
     if (isset($filters['adv_channel_id'])) {
         $model = AdvertiseChannel::model()->findByPk($filters['adv_channel_id']);
         if ($model) {
             $conditions[] = "包名:{$model->tag}";
         }
     }
     /*end*/
     if (isset($filters['begin_date']) && isset($filters['end_date'])) {
         $conditions[] = "从{$filters['begin_date']}到{$filters['end_date']}";
     }
     if (isset($filters['date'])) {
         $conditions[] = "日期:{$filters['date']}";
     }
     if (count($conditions)) {
         return $this->getTableBaseName() . '-(' . join('-', $conditions) . ')';
     } else {
         return $this->getTableBaseName() . '-全部';
     }
 }
Esempio n. 8
0
 /**
  * Returns the static model of the specified AR class.
  * @param string $className active record class name.
  * @return Advertise the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }