/** * 广告修改 */ public function editAction() { if ($this->_request->isPost()) { $aAd = $this->_checkData('update'); if (empty($aAd)) { return null; } $aAd['iAdID'] = intval($this->getParam('iAdID')); $aOldAd = Model_Ad::getDetail($aAd['iAdID']); if (empty($aOldAd)) { return $this->showMsg('广告不存在!', false); } if (1 == Model_Ad::updData($aAd)) { if ($aOldAd['iStatus'] == Model_Ad::STATUS_WAIT_APPROVE || $aOldAd['iStatus'] == Model_Ad::STATUS_APPROVE_NO && $aAd['iStatus'] == Model_Ad::STATUS_APPROVE_OK) { $aMediaList = Model_AdMedia::getMediaByAd($aAd['iAdID'], Model_AdMedia::STATUS_CHECK, 1); foreach ($aMediaList as $aMedia) { Model_AdMedia::updStatus($aMedia['iAutoID'], Model_AdMedia::STATUS_RECEIVE); } // 邮件通知 $sTitle = Model_Kv::getValue('media_receive_order_email_title'); $sContent = Model_Kv::getValue('media_receive_order_email_content'); // 短信通知 $iTempID = Util_Common::getConf(3, 'aSmsTempID'); foreach ($aMediaList as $aMedia) { $aUser = Model_User::getDetail($aMedia['iMUserID']); Util_Mail::send($aUser['sEmail'], $sTitle, $sContent, array($aMedia['iMoney'])); Util_Sms::sendTemplateSms($aUser['sMobile'], array($aMedia['iMoney']), $iTempID); // echo $sTitle, "\n", $sContent, "\n", $aUser['sEmail'], $aUser['sMobile'], $iTempID; } } return $this->showMsg('广告更新成功!', true); } else { return $this->showMsg('广告更新失败!', false); } } else { $iAdID = intval($this->getParam('id')); $aAd = Model_Ad::getDetail($iAdID); $aAd['iMoney'] = Model_AdMedia::getDetail($aAd['iAdID'])['iMoney']; $aAd['sCatID'] = isset($aAd['sCatID']) && sCatID != '' ? explode(',', $aAd['sCatID']) : ''; $aAd['sCityID'] = isset($aAd['sCityID']) && sCatID != '' ? explode(',', $aAd['sCityID']) : ''; $iType = $aAd['iMediaType']; $aCategory = array(); switch ($iType) { case Model_Media::TYPE_WEIXIN: $aCategory = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_WEIXIN_CATEGORY); break; case Model_Media::TYPE_FRIEND: $aCategory = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_FRIEND_CATEGORY); break; case Model_Media::TYPE_WEIBO: $aCategory = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_WEIBO_CATEGORY); break; case Model_Media::TYPE_NEWS: $aCategory = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_NEWS_CATEGORY); break; } $aCity = Model_City::getPairCitys(Model_City::TYPE_FRONT); $aUser = Model_User::getDetail($aAd['iUserID']); $this->assign('aUser', $aUser); $this->assign('aAd', $aAd); $this->assign('aCategory', $aCategory); $this->assign('aCity', $aCity); } }
/** * 更新设置详情 * * @param unknown $aAd * @param unknown $aData */ public static function setSetting($aAd, $aData) { $sModel = self::getSettingModel($aAd['iMediaType']); $aSetting = self::getSetting($aAd); if (empty($aSetting)) { $sModel::addData($aData); } else { $sModel::updData($aData); } Model_Ad::updData(array('iPlanTime' => $aData['iPlanTime'], 'iAdID' => $aAd['iAdID'])); self::query('UPDATE t_ad_media SET iPlanTime="' . $aData['iPlanTime'] . '",iAdPos=' . $aData['iAdPos'] . ' WHERE iAdID=' . $aAd['iAdID']); self::query('UPDATE t_ad_media am,t_media m SET am.iMoney=m.iPrice' . $aData['iAdPos'] . ' WHERE am.iAdID=' . $aAd['iAdID'] . ' AND am.iMediaID=m.iMediaID'); // 修改状态为待审核 self::updData(array('iAdID' => $aAd['iAdID'], 'iStatus' => self::STATUS_WAIT_APPROVE)); }
/** * 添加推广 */ 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' => '添加推广计划')); } }
/** * 广告修改 */ public function editAction() { if ($this->_request->isPost()) { $aAd = $this->_checkData('update'); if (empty($aAd)) { return null; } $aAd['iAdID'] = intval($this->getParam('iAdID')); $aOldAd = Model_Ad::getDetail($aAd['iAdID']); if (empty($aOldAd)) { return $this->showMsg('广告不存在!', false); } if (1 == Model_Ad::updData($aAd)) { return $this->showMsg('广告更新成功!', true); } else { return $this->showMsg('广告更新失败!', false); } } else { $iAdID = intval($this->getParam('id')); $aAd = Model_Ad::getDetail($iAdID); $aAd['sCatID'] = isset($aAd['sCatID']) && sCatID != '' ? explode(',', $aAd['sCatID']) : ''; $aAd['sCityID'] = isset($aAd['sCityID']) && sCatID != '' ? explode(',', $aAd['sCityID']) : ''; $iType = $aAd['iMediaType']; $aCategory = array(); switch ($iType) { case Model_Media::TYPE_WEIXIN: $aCategory = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_WEIXIN_CATEGORY); break; case Model_Media::TYPE_FRIEND: $aCategory = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_FRIEND_CATEGORY); break; case Model_Media::TYPE_WEIBO: $aCategory = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_WEIBO_CATEGORY); break; case Model_Media::TYPE_NEWS: $aCategory = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_NEWS_CATEGORY); break; } $aCity = Model_City::getPairCitys(Model_City::TYPE_FRONT); $aAd['iMoney'] = Model_AdMedia::getDetail($aAd['iAdID'])['iMoney']; $aUser = Model_User::getDetail($aAd['iUserID']); $this->assign('aUser', $aUser); $this->assign('aAd', $aAd); $this->assign('aCategory', $aCategory); $this->assign('aCity', $aCity); } }