Beispiel #1
0
 /**
  * 增加广告
  */
 public function addAction()
 {
     if ($this->_request->isPost()) {
         $aAd = $this->_checkData('add');
         if (empty($aAd)) {
             return null;
         }
         if (Model_Ad::addData($aAd) > 0) {
             return $this->showMsg('广告增加成功!', true);
         } else {
             return $this->showMsg('广告增加失败!', false);
         }
     }
 }
Beispiel #2
0
 /**
  * 添加推广
  */
 public function addAction()
 {
     if ($this->isPost()) {
         $iAdID = (int) $this->getParam('id');
         $aAd = null;
         if ($iAdID > 0) {
             $aAd = Model_Ad::getDetail($iAdID);
             if ($aAd['iUserID'] != $this->aCurrUser['iUserID']) {
                 return $this->showMsg('不要乱改别人的数据', false);
             }
         }
         $aData = array();
         $aData['iUserID'] = $this->aCurrUser['iUserID'];
         $aData['iMediaType'] = (int) $this->getParam('iMediaType');
         $aData['iAdType'] = (int) $this->getParam('iAdType');
         $aData['sAdName'] = $this->getParam('sAdName');
         $aData['iPlanMinMoney'] = (int) $this->getParam('iPlanMinMoney');
         $aData['iPlanMaxMoney'] = (int) $this->getParam('iPlanMaxMoney');
         $aData['sCatID'] = (int) $this->getParam('sCatID');
         $aAdType = $this->getParam('aAdType');
         $aCityID = $this->getParam('aCityID');
         $aErr = array();
         if (!Util_Validate::isLength($aData['sAdName'], 2, 50)) {
             $aErr['sAdName'] = '请输入推广名称';
         }
         if ($aData['iPlanMinMoney'] > $aData['iPlanMaxMoney']) {
             $aErr['iPlanMoney'] = '后者数字必须大于前者数字';
         }
         /*
          * if (empty($aAdType)) { $aErr['aAdType'] = '请选择广告类型'; } if (empty($aCatID)) { $aErr['aCatID'] = '请选择媒体类别'; }
          */
         /*
          * if (empty($aCityID)) { $aErr['aCityID'] = '请选择城市/地区'; }
          */
         if (!empty($aCityID) && count($aCityID) > 3) {
             $aErr['aCityID'] = '最多选择3个城市/地区';
         }
         // 判断该自媒是否已经存在
         if (!empty($aData['sAdName'])) {
             $aOtherAd = Model_Ad::getAdByName($aData['iUserID'], $aData['sAdName'], $iAdID);
             if (!empty($aOtherAd) && $aOtherAd['iStatus'] != Model_Ad::STATUS_DELETE) {
                 $aErr['sAdName'] = '该推广计划已经存在!';
             }
         }
         if (!empty($aErr)) {
             return $this->showMsg($aErr, false);
         }
         /*
          * if (count($aAdType) == 2) { $aData['iAdType'] = 3; } else { $aData['iAdType'] = array_pop($aAdType); }
          */
         $aData['sCityID'] = empty($aCityID) ? '' : join(',', $aCityID);
         $aData['iStatus'] = Model_Ad::STATUS_WRITING;
         if (empty($aAd)) {
             $iAdID = Model_Ad::addData($aData);
         } else {
             $aData['iAdID'] = $aAd['iAdID'];
             Model_Ad::updData($aData);
         }
         Model_User::updData(array('iUserID' => $this->aCurrUser['iUserID'], 'iFirst' => 'iFirst + 1'));
         if ($iAdID > 0) {
             return $this->showMsg($iAdID, true);
         } else {
             $aErr['sAdName'] = '添加失败,请稍后再试';
             return $this->showMsg($aErr, false);
         }
     } else {
         $iAdID = intval($this->getParam('id'));
         $aAd = null;
         if ($iAdID > 0) {
             $aAd = Model_Ad::getDetail($iAdID);
         }
         if (empty($aAd)) {
             $iType = intval($this->getParam('type', Model_Media::TYPE_WEIXIN));
         } else {
             $iType = $aAd['iMediaType'];
             $aAd['aCityID'] = explode(',', $aAd['sCityID']);
             $aAd['aCatID'] = explode(',', $aAd['sCatID']);
         }
         $aData = array();
         switch ($iType) {
             case Model_Media::TYPE_WEIXIN:
                 $aData['aCategory'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_WEIXIN_CATEGORY);
                 // $aData['aTag'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_WEIXIN_TAG);
                 break;
             case Model_Media::TYPE_FRIEND:
                 $aData['aCategory'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_FRIEND_CATEGORY);
                 // $aData['aTag'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_FRIEND_TAG);
                 break;
             case Model_Media::TYPE_WEIBO:
                 $aData['aCategory'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_WEIBO_CATEGORY);
                 // $aData['aTag'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_WEIBO_TAG);
                 break;
             case Model_Media::TYPE_NEWS:
                 $aData['aCategory'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_NEWS_CATEGORY);
                 // $aData['aTag'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_NEWS_TAG);
                 break;
         }
         $aData['aAdType'] = array(1 => '软广', 2 => '硬广');
         $aData['aCity'] = Model_City::getPairCitys(Model_City::TYPE_FRONT);
         $aType = Model_Media::$aType;
         unset($aType[Model_Media::TYPE_NEWS]);
         $this->assign('iType', $iType);
         $this->assign('aType', $aType);
         $this->assign('aData', $aData);
         $this->assign('aAd', $aAd);
         $this->assign('aUser', Model_User::getDetail($this->aCurrUser['iUserID']));
         $this->assign('sTopMenu', 'aadd');
         $this->setMeta('ad_add', array('sTitle' => '添加推广计划'));
     }
 }