/** * 更新自媒体分类 * * @param unknown $iAdID * @param unknown $aNewMediaID */ public static function updMedia($iAdID, $aNewMediaID, $iUserID) { $aOldMediaID = Model_AdMedia::getPair(array('where' => array('iAdID' => $iAdID, 'iStatus' => 1)), 'iAutoID', 'iMediaID'); $aNewMediaID = array_flip($aNewMediaID); $aOldMediaID = array_flip($aOldMediaID); foreach ($aOldMediaID as $iMediaID => $iAutoID) { if (isset($aNewMediaID[$iMediaID])) { continue; } Model_AdMedia::realDelData($iAutoID); } foreach ($aNewMediaID as $iMediaID => $iAutoID) { if (isset($aOldMediaID[$iMediaID])) { continue; } $aMedia = Model_Media::getDetail($iMediaID); Model_AdMedia::addData(array('iAdID' => $iAdID, 'iMediaID' => $iMediaID, 'iAUserID' => $iUserID, 'iMUserID' => $aMedia['iUserID'], 'iPos' => 1, 'iMoney' => 0, 'iPlanTime' => 0, 'iStatus' => 1)); } }
/** * 推广详情 */ public function adAction() { $iAdID = (int) $this->getParam('id', 0); $aAd = Model_Ad::getDetail($iAdID); if (empty($aAd)) { return $this->show404(); } $aSetting = Model_Ad::getSetting($aAd); if (!empty($aSetting) && isset($aSetting['sForwardImg'])) { $aSetting['aForwardImg'] = explode(',', $aSetting['sForwardImg']); } $aList = Model_AdMedia::getAll(array('iAdID' => $iAdID, 'iChoose' => 1, 'iStatus >' => 0)); foreach ($aList as $k => &$aRow) { $aRow['aAd'] = Model_Ad::getDetail($aRow['iAdID']); $aRow['aMedia'] = Model_Media::getDetail($aRow['iMediaID']); } $this->assign('aStatus', Model_AdMedia::$aStatus); $this->assign('aTitle', Model_Media::$aPos[$aAd['iMediaType']]); $this->assign('aSetting', $aSetting); $this->assign('aAd', $aAd); $this->assign('aList', $aList); $this->assign('iType', $this->getParam('type', 1)); $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)) { 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); } }
/** * 支付款项 */ public function add4Action() { if ($this->isPost()) { $iAdID = $this->getParam('iAdID'); $aChoose = $this->getParam('aChoose'); $aAdPos = $this->getParam('aAdPos'); $aAd = Model_Ad::getDetail($iAdID); if (empty($aAd) || $aAd['iUserID'] != $this->aCurrUser['iUserID']) { return $this->show404(); } if (empty($aChoose)) { return $this->showMsg('请至少选择一个自媒体', false); } Model_AdMedia::updChoose($iAdID, $aChoose, $aAdPos); return $this->showMsg($iAdID, true); } else { $iAdID = intval($this->getParam('id')); $aAd = Model_Ad::getDetail($iAdID); if (empty($aAd) || $aAd['iUserID'] != $this->aCurrUser['iUserID']) { return $this->show404(); } $aList = Model_AdMedia::getAll(array('where' => array('iAdID' => $iAdID, 'iStatus !=' => 0))); $iTotalMoney = $iTotalMedia = 0; foreach ($aList as $k => &$v) { $v['aMedia'] = Model_Media::getDetail($v['iMediaID']); if (empty($v['aMedia'])) { unset($aList[$k]); } if ($v['iChoose']) { $iTotalMoney += $v['iMoney']; $iTotalMedia += 1; } } $this->assign('iTotalMoney', $iTotalMoney); $this->assign('iTotalMedia', $iTotalMedia); $this->assign('aList', $aList); $this->assign('aAd', $aAd); $this->assign('aStatus', Model_AdMedia::$aStatus); $this->assign('aPos', Model_Media::$aPos[$aAd['iMediaType']]); $this->assign('aType', Model_Media::$aType); $this->assign('sMediaType', Model_Media::$aType[$aAd['iMediaType']]); $this->assign('sTopMenu', 'aadd'); $this->setMeta('ad_add', array('sTitle' => '添加推广计划 - 支付款项')); } }
/** * 提交效果 * * @return boolean */ public function effectAction() { $iAutoID = (int) $this->getParam('id'); $aAdMedia = Model_AdMedia::getDetail($iAutoID); if (empty($aAdMedia)) { return $this->show404(); } if ($aAdMedia['iStatus'] != Model_AdMedia::STATUS_SUBMIT_EFFECT) { return $this->show404(); } if ($this->isPost()) { $sEffectImg = $this->getParam('sEffectImg'); $aErr = array(); if (empty($sEffectImg)) { $aErr['sEffectImg'] = '请上传效果图'; } if (!empty($aErr)) { return $this->showMsg($aErr, false); } Model_AdMedia::updData(array('iAutoID' => $iAutoID, 'sEffectImg' => $sEffectImg, 'iStatus' => Model_AdMedia::STATUS_CONFIRM_EFFECT)); // 邮件通知 $sTitle = Model_Kv::getValue('media_runing_email_title'); $sContent = Model_Kv::getValue('media_runing_email_content'); // 短信通知 $iTempID = Util_Common::getConf(7, 'aSmsTempID'); $aUser = Model_User::getDetail($aAdMedia['iAUserID']); $aMedia = Model_Media::getDetail($aAdMedia['iMediaID']); Util_Tools::sendMail($aUser['sEmail'], $sTitle, $sContent, array($aMedia['sMediaName'])); Util_Sms::sendTemplateSms($aUser['sMobile'], array($aMedia['sMediaName']), $iTempID); return $this->showMsg('执行效果图提交成功', true); } else { $this->assign('aAdMedia', $aAdMedia); $this->setMeta('mcenter_page', 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); } }
/** * 导出 */ public function explodeAction() { $uWhere = array(); $aParam = $this->getParams(); $userid = ''; if (!empty($aParam['sRealName'])) { $uWhere['sRealName LIKE'] = '%' . $aParam['sRealName'] . '%'; $data_user = Model_User::getAll(array('where' => $uWhere)); $useridArr = array(); foreach ($data_user as $val) { if ($val['iUserID'] != '') { $useridArr[] = $val['iUserID']; } } if (count($useridArr) > 0) { $userid = implode(',', array_unique($useridArr)); } } $aWhere = array(); if (!empty($aParam['iUserID'])) { $aWhere['iUserID'] = $aParam['iUserID']; } if ($userid != '') { $aWhere['iUserID IN'] = $userid; } if (!empty($aParam['iPayment']) && $aParam['iPayment'] != '') { $aWhere['iPayment'] = $aParam['iPayment']; } if (!empty($aParam['iSource']) && $aParam['iSource'] != '') { $aWhere['iSource'] = $aParam['iSource']; } if (!empty($aParam['sRealName']) && $aParam['sRealName'] != '') { $aWhere['sRealName LIKE'] = '%' . $aParam['sRealName'] . '%'; } if (!empty($aParam['iPayType']) && $aParam['iPayType'] != '') { $aWhere['iPayType'] = $aParam['iPayType']; } if (!empty($aParam['iPayStatus']) && $aParam['iPayStatus'] != '') { $aWhere['iPayStatus'] = $aParam['iPayStatus']; } $aList = Model_AdMedia::getAll(array('where', $aWhere)); header("Content-type:application/vnd.ms-excel"); header("Content-Disposition:filename=资源订单_" . date('Y-m-d', time()) . ".xls"); $str_explode = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html xmlns='http://www.w3.org/1999/xhtml'><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8' /><title>导出</title><style>td{text-align:center;font-size:12px;font-family:Arial, Helvetica, sans-serif;border:#1C7A80 1px solid;color:#152122;width:100px;}table,tr{border-style:none;}.title{background:#7DDCF0;color:#FFFFFF;font-weight:bold;}</style></head><body>"; $str_explode .= '<table cellspacing="0" cellpadding="3" rules="rows" border="1" id="" style="border-style:None;width:100%;border-collapse:collapse;"> <tr> <th scope="col">用户名称/th> <th scope="col">广告名称</th> <th scope="col">资源媒体名称</th> <th scope="col">广告位</th> <th scope="col">价格</th> <th scope="col">执行时间</th> <th scope="col">支付状态</th> <th scope="col">状态</th> <th scope="col">时间</th> </tr>'; foreach ($aList as $key => $val) { $aAd = Model_Ad::getDetail($val['iAdID']); //资源 $aMedia = Model_Media::getDetail($val['iMediaID']); $sMediaName = $aMedia['sMediaName']; //用户 $aUser = Model_User::getDetail($val['iUserID']); $sEmail = $aUser['sEmail']; //广告位 $aTitle = array(Model_Media::TYPE_WEIXIN => array('1' => '单图文报价', '2' => '第一条报价', '3' => '第二条报价', '4' => '其它位置价'), Model_Media::TYPE_FRIEND => array('1' => '转发报价', '2' => '直发报价'), Model_Media::TYPE_WEIBO => array('1' => '转发报价', '2' => '直发报价')); $iPos = ''; if ($aAd['iMediaType'] != '') { $iPos = $aTitle[$aAd['iMediaType']][$val['iPos']]; } //支付状态 $iPayStatusName = ''; if ($val['iPayStatus'] == '0') { $iPayStatusName = '未支付'; } elseif ($val['iPayStatus'] == '1') { $iPayStatusName = '已支付'; } $iMoney = $val['iMoney']; $iPlanTime = ''; if ($val['iPlanTime'] != '' && $val['iPlanTime'] > 0) { $iPlanTime = date('Y-m-d H:i', $val['iPlanTime']); } //状态 $iStatusName = ''; if ($val['iStatus'] == '1') { $iStatusName = '等待接单'; } elseif ($val['iStatus'] == '2') { $iStatusName = '等待执行'; } elseif ($val['iStatus'] == '3') { $iStatusName = '执行中'; } elseif ($val['iStatus'] == '4') { $iStatusName = '已完成'; } elseif ($val['iStatus'] == '5') { $iStatusName = '拒绝接单'; } $iCreateTime = date('Y-m-d H:i:s', $val['iCreateTime']); $str_explode .= '<tr> <td align="left">' . $sEmail . '</td> <td align="left">' . $aAd['sAdName'] . '</td> <td align="left">' . $sMediaName . '</td> <td align="left">' . $iPos . '</td> <td align="left">' . $iMoney . '</td> <td align="left">' . $iPlanTime . '</td> <td align="left">' . $iPayStatusName . '</td> <td align="left">' . $iStatusName . '</td> <td align="left">' . $iCreateTime . '</td> </tr>'; } $str_explode .= '</table>'; $str_explode .= "</body></html>"; echo $str_explode; }
/** * 自媒体中心 */ public function indexAction() { $aParam = $this->getParams(); $aParam['type'] = isset($aParam['type']) ? intval($aParam['type']) : Model_Media::TYPE_WEIXIN; $iAdID = (int) $this->getParam('id'); $aAd = null; if ($iAdID > 0) { $aAd = Model_Ad::getDetail($iAdID); } if (!empty($aAd)) { $aParam['type'] = $aAd['iMediaType']; $sReferer = $this->getRequest()->getHttpReferer(); if (strpos($sReferer, '/ad/add') > 0) { if (!empty($aAd['sCatID'])) { $aParam['catid'] = intval($aAd['sCatID']); } if (!empty($aAd['sCityID'])) { $aParam['city'] = explode(',', $aAd['sCityID']); } } } $aData = Model_Media::search($aParam); foreach ($aData['aList'] as &$aRow) { $aRow['sCatName'] = Model_Media::getCategoryNames($aRow['iMediaID']); } switch ($aParam['type']) { case Model_Media::TYPE_WEIXIN: $aData['aType'] = 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['aType'] = 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['aType'] = 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['aType'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_NEWS_CATEGORY); $aData['aTag'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_NEWS_TAG); break; } $aData['aPrice'] = Model_Price::getOption(); $aData['aFollower'] = Model_Follower::getOption(); $aData['aCity'] = Model_City::getPairCitys(Model_City::TYPE_FRONT); $aData['aLevel'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_RECOMMEND); $aData['aAd'] = $aAd; if (!empty($aData['aAd'])) { $aData['aChooseID'] = Model_AdMedia::getCol(array('where' => array('iStatus >' => 0, 'iAdID' => $iAdID)), 'iMediaID'); } if (empty($aData['aChooseID'])) { $sCookieKey = 'media_choose_' . $aParam['type']; $aData['aChooseID'] = !empty($_COOKIE[$sCookieKey]) ? explode(',', $_COOKIE[$sCookieKey]) : array(); } $aData['aChoose'] = array(); foreach ($aData['aChooseID'] as $k => $v) { $aMedia = Model_Media::getDetail($v); if (empty($aMedia)) { continue; } $aData['aChoose'][] = $aMedia; } $this->assign('aData', $aData); $this->assign('aParam', $aParam); $this->assign('sTopMenu', empty($aAd) ? 'media' : 'aadd'); $this->setMeta('media_center', array('sTitle' => '媒体中心')); }
/** * 投放完成(结算) * * @return boolean */ public function finishAction() { $iAutoID = intval($this->getParam('id')); $aAdMedia = Model_AdMedia::getDetail($iAutoID); if (empty($aAdMedia)) { return $this->showMsg('数据出错了', false); } if ($aAdMedia['iStatus'] != Model_AdMedia::STATUS_CONFIRM_EFFECT) { return $this->showMsg('你已经处理过了', false); } $aAd = Model_Ad::getDetail($aAdMedia['iAdID']); Model_AdMedia::begin(); Model_AdMedia::updStatus($iAutoID, Model_AdMedia::STATUS_FINISHED); Model_Finance::updMoney($aAdMedia['iMUserID'], array('iPayment' => Model_Finance::PAYMENT_IN, 'iSource' => Model_Finance::SOURCE_AD_CASH_IN, 'iPayType' => Model_Finance::TYPE_NO, 'iMoney' => $aAdMedia['iMoney'])); Model_AdMedia::commit(); // 邮件通知 $sTitle = Model_Kv::getValue('ad_approve_preview_email_title'); $sContent = Model_Kv::getValue('ad_approve_preview_email_content'); // 短信通知 $iTempID = Util_Common::getConf(6, 'aSmsTempID'); $aUser = Model_User::getDetail($aAdMedia['iMUserID']); $aMedia = Model_Media::getDetail($aAdMedia['iMediaID']); Util_Mail::send($aUser['sEmail'], $sTitle, $sContent, array($aMedia['sEmail'])); Util_Sms::sendTemplateSms($aUser['sMobile'], array($aMedia['sEmail']), $iTempID); // echo $sTitle, "\n", $sContent, "\n", $aUser['sEmail'], $aUser['sMobile'], $iTempID; return $this->showMsg('操作成功', true); }