/** * Checks if a given media already exists creating it if it doesn't * * @param string $url The media url * @param Model_Droplet $droplet_id Droplet id this media belongs to * @param Model_Account $account_id Account id this media belongs to * @return Model_Account_Droplet_Media */ public static function get_media($url, $droplet_id, $account_id) { $orm_media = Model_Media::get_media_by_url($url, TRUE); $account_media = ORM::factory('account_droplet_media')->where('droplet_id', '=', $droplet_id)->where('media_id', '=', $orm_media->id)->where('account_id', '=', $account_id)->find(); if (!$account_media->loaded()) { $account_media->media_id = $orm_media->id; $account_media->droplet_id = $droplet_id; $account_media->account_id = $account_id; $account_media->save(); } return $account_media; }
/** * 统计抓取数据 */ public function statcrawlAction() { $iLast1Day = strtotime('-1day'); $iWeixinCreateCnt = Model_Media::query('SELECT COUNT(*) FROM t_crawl_weixin WHERE iCreateTime>=' . $iLast1Day, 'one'); $iWeixinUpdateCnt = Model_Media::query('SELECT COUNT(*) FROM t_crawl_weixin WHERE iUpdateTime>=' . $iLast1Day, 'one'); $iArticeCreateCnt = Model_Media::query('SELECT COUNT(*) FROM t_crawl_weixin_article WHERE iCreateTime>=' . $iLast1Day, 'one'); $iArticeUpdateCnt = Model_Media::query('SELECT COUNT(*) FROM t_crawl_weixin_article WHERE iUpdateTime>=' . $iLast1Day, 'one'); $sBody = "\n 今天数据抓取结果如下:<br>\n\n 微信公众号新增:{$iWeixinCreateCnt}个<br>\n\n 微信公众号更新:{$iWeixinUpdateCnt}个<br>\n\n 微信文章新增:{$iArticeCreateCnt}个<br>\n\n "; echo $sBody; $aTo = array('*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**'); Util_Mail::send('*****@*****.**', '51wom数据抓取结果(' . date('Y-m-d') . ')', $sBody); }
/** * 更新选择 * * @param unknown $iAdID * @param unknown $aChoose */ public static function updChoose($iAdID, $aChoose, $aAdPos) { self::query('UPDATE t_ad_media SET iChoose=0 WHERE iAdID=' . $iAdID); // self::query('UPDATE t_ad_media SET iChoose=1 WHERE iAutoID IN(' . join(',', $aChoose) . ')'); foreach ($aChoose as $iAutoID) { if (!isset($aAdPos[$iAutoID])) { continue; } $aAdMedia = self::getDetail($iAutoID); $aMedia = Model_Media::getDetail($aAdMedia['iMediaID']); self::updData(array('iAutoID' => $iAutoID, 'iChoose' => 1, 'iAdPos' => $aAdPos[$iAutoID], 'iMoney' => $aMedia['iPrice' . $aAdPos[$iAutoID]])); } self::query('UPDATE t_ad SET iTotalMoney=(SELECT SUM(iMoney) FROM t_ad_media WHERE iAdID=' . $iAdID . ' AND iChoose=1 AND iStatus>0) WHERE iAdID=' . $iAdID); }
/** * 更新自媒体分类 * * @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)); } }
/** * 执行Action后的操作 * * @see Yaf_Controller::actionAfter() */ public function actionAfter() { if ($this->autoRender() == true) { $aDebug = Util_Common::getDebugData(); if ($aDebug) { $this->assign('__showDebugInfo__', 'showDebugInfo(' . json_encode($aDebug) . ');'); } $this->assign('_iMediaTotal', Model_Media::getCnt(array('where' => array('iStatus' => 1)))); $this->assign('_iYAdTotal', Model_Ad::getYesterdayAdCnt()); $this->assign('_iYUserTotal', Model_Ad::getYesterdayUserCnt()); if (empty($this->aCurrUser)) { $this->aCurrUser = $this->getCurrUser(Model_User::TYPE_AD, false); if (empty($this->aCurrUser)) { $this->aCurrUser = $this->getCurrUser(Model_User::TYPE_MEDIA, false); } } $this->assign('_aCurrUser', $this->aCurrUser); } else { } }
/** * 推广详情 */ 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' => '添加推广计划 - 支付详情')); }
/** * 投放完成(结算) * * @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); }
/** * 导出自媒体 */ public function exportAction() { $iType = $this->getParam('type', 1); $sCookieKey = 'media_choose_' . $iType; $aData['aChooseID'] = !empty($_COOKIE[$sCookieKey]) ? explode(',', $_COOKIE[$sCookieKey]) : array(); $aData['aChoose'] = array(); foreach ($aData['aChooseID'] as $k => $v) { $aRow = Model_Media::getDetail($v); $aRow['sTags'] = Model_Media::getTagNames($v['iMediaID']); $aRow['sCitys'] = Model_Media::getCityNames($v['iMediaID']); $aData['aChoose'][] = $aRow; } $aTitle = array(Model_Media::TYPE_WEIXIN => array('sMediaName' => '帐号名称', 'sOpenName' => '公众号', 'iFollowerNum' => '粉丝量', 'iPrice1' => '单图文价格', 'iPrice2' => '第一条价格', 'iPrice3' => '第二条价格', 'iPrice4' => '其它位置价格', 'iReadNum' => '阅读数', 'sIntroduction' => '简介', 'sTags' => '标签', 'sCertifiedText' => '认证', 'sCitys' => '地区'), Model_Media::TYPE_FRIEND => array('sMediaName' => '微信号', 'iFollowerNum' => '好友数', 'iPrice1' => '直发价格', 'iPrice2' => '转发价格'), Model_Media::TYPE_WEIBO => array('sMediaName' => '微博名', 'iFollowerNum' => '好友数', 'iPrice1' => '直发价格', 'iPrice2' => '转发价格')); Util_File::exportCsv('自媒体表-' . date('Ymd') . '.csv', $aData['aChoose'], $aTitle[$iType]); return false; }
/** * 导出资源数据 */ public function explodeAction() { $iPage = intval($this->getParam('page')); $aWhere = array(); $aParam = $this->getParams(); if (!empty($aParam['iUserID'])) { $aWhere['iUserID'] = $aParam['iUserID']; } if (!empty($aParam['iMediaType'])) { $aWhere['iMediaType'] = $aParam['iMediaType']; } if (!empty($aParam['sMediaName'])) { $aWhere['sMediaName LIKE'] = '%' . $aParam['sMediaName'] . '%'; } if (!empty($aParam['iStatus'])) { $aWhere['iStatus'] = $aParam['iStatus']; } else { $aWhere['iStatus IN'] = '1,2'; } $aList = Model_Media::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">报价1</th> <th scope="col">报价2</th> <th scope="col">报价3</th> <th scope="col">报价4</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> <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> <th scope="col">标签</th> </tr>'; foreach ($aList as $key => $val) { $id = $val['iMediaID']; $row = Model_User::getDetail($val['iUserID']); $sRealName = isset($row) && $row['sRealName'] != '' ? $row['sRealName'] : ''; $iMediaType = ''; if ($val['iMediaType'] == '1') { $iMediaType = '微信'; } elseif ($val['iMediaType'] == '2') { $iMediaType = '微博'; } elseif ($val['iMediaType'] == '3') { $iMediaType = '朋友圈'; } elseif ($val['iMediaType'] == '4') { $iMediaType = '新闻'; } $sMediaName = $val['sMediaName']; $sOpenName = $val['sOpenName']; $iFollowerNum = $val['iFollowerNum']; $sFollowerImg = Util_Uri::getDFSViewURL($val['sFollowerImg'], 130, 130); $sAvatar = Util_Uri::getDFSViewURL($val['sAvatar'], 130, 130); $sQRCode = Util_Uri::getDFSViewURL($val['sQRCode'], 130, 130); $iPrice5 = $val['iPrice5']; $iPrice6 = $val['iPrice6']; $iPrice7 = $val['iPrice7']; $iPrice8 = $val['iPrice8']; $iReadNum = $val['iReadNum']; $iScore = $val['iScore']; $iRecommendLevel = $val['iRecommendLevel']; $iPersonCharge = $val['iPersonCharge']; $iAuditperson = $val['iAuditperson']; $rowattr = Model_Domain::getDetail($val['iAttribute']); $iAttribute = isset($rowattr['sName']) ? $rowattr['sName'] : ''; //属性 $sWxLink = $val['sWxLink']; $rowver = Model_Domain::getDetail($val['iVerifyState']); $iVerifyState = isset($rowver['sName']) ? $rowver['sName'] : ''; //认证 $sIntroduction = $val['sIntroduction']; $sTypeInfo = $val['sTypeInfo']; $sCooperateLevelInfo = ''; if ($val['sCooperateLevelInfo'] != '') { $rowlevel = Model_Domain::getAll(array('where' => array('iAutoID IN' => $val['sCooperateLevelInfo']))); //合作等级 if (isset($rowlevel) && count($rowlevel) > 0) { foreach ($rowlevel as $lrow) { $sCooperateLevelInfo .= ' ' . $lrow['sName']; } } } $sCertifiedText = $val['sCertifiedText']; $iClickNumber = $val['iClickNumber']; $iChoiceNumber = $val['iChoiceNumber']; $iArticleNumber = $val['iArticleNumber']; $iZambiaNumber = $val['iZambiaNumber']; //分类 $data_cat = Model_MediaCategory::getAll(array('where' => array('iMediaID' => $val['iMediaID'], 'iStatus' => 1))); $aCategory = ''; if (isset($data_cat) && count($data_cat) > 0) { $iAutoID = array(); foreach ($data_cat as $val_cat) { $iAutoID[] = $val_cat['iCategoryID']; } if (count($iAutoID) > 0) { $rowcat = Model_Domain::getAll(array('where' => array('iAutoID IN' => implode(',', array_unique($iAutoID)), 'iStatus' => '1'))); if (isset($rowcat) && count($rowcat) > 0) { foreach ($rowcat as $vcat) { $aCategory .= ',' . $vcat['sName']; } } } } //城市 $data_city = Model_MediaCity::getAll(array('where' => array('iMediaID' => $val['iMediaID'], 'iStatus' => 1))); $aCity = ''; if (isset($data_city) && count($data_city) > 0) { $iAutoID = array(); foreach ($data_city as $val_City) { $iAutoID[] = $val_City['iCityID']; } if (count($iAutoID) > 0) { $rowCity = Model_Domain::getAll(array('where' => array('iAutoID IN' => implode(',', array_unique($iAutoID)), 'iStatus' => '1'))); if (isset($rowCity) && count($rowCity) > 0) { foreach ($rowCity as $vCity) { $aCity .= ',' . $vCity['sName']; } } } } //圈子 $data_cricle = Model_MediaCricle::getAll(array('where' => array('iMediaID' => $val['iMediaID'], 'iStatus' => 1))); $aCricle = ''; if (isset($data_cricle) && count($data_cricle) > 0) { $iAutoID = array(); foreach ($data_cricle as $val_Cricle) { $iAutoID[] = $val_Cricle['iCricleID']; } if (count($iAutoID) > 0) { $rowCricle = Model_Domain::getAll(array('where' => array('iAutoID IN' => implode(',', array_unique($iAutoID)), 'iStatus' => '1'))); if (isset($rowCricle) && count($rowCricle) > 0) { foreach ($rowCricle as $vCricle) { $aCricle .= ',' . $vCricle['sName']; } } } } //标签 $data_tag = Model_MediaTag::getAll(array('where' => array('iMediaID' => $val['iMediaID'], 'iStatus' => 1))); $aTag = ''; if (isset($data_tag) && count($data_tag) > 0) { $iAutoID = array(); foreach ($data_tag as $val_Tag) { $iAutoID[] = $val_Tag['iTagID']; } if (count($iAutoID) > 0) { $rowTag = Model_Domain::getAll(array('where' => array('iAutoID IN' => implode(',', array_unique($iAutoID)), 'iStatus' => '1'))); if (isset($rowTag) && count($rowTag) > 0) { foreach ($rowTag as $vTag) { $aTag .= ',' . $vTag['sName']; } } } } $iCreateTime = date('Y-m-d H:i:s', $val['iCreateTime']); $str_explode .= '<tr> <td align="left">' . $sRealName . '</td> <td align="left">' . $iMediaType . '</td> <td align="left">' . $sMediaName . '</td> <td align="left">' . $sOpenName . '</td> <td align="left">' . $iFollowerNum . '</td> <td align="left"><img src="' . $sFollowerImg . '" /></td> <td align="left"><img src="' . $sAvatar . '" /></td> <td align="left"><img src="' . $sQRCode . '" /></td> <td align="left">' . $iPrice5 . '</td> <td align="left">' . $iPrice6 . '</td> <td align="left">' . $iPrice7 . '</td> <td align="left">' . $iPrice8 . '</td> <td align="left">' . $iReadNum . '</td> <td align="left">' . $iScore . '</td> <td align="left">' . $iRecommendLevel . '</td> <td align="left">' . $iAttribute . '</td> <td align="left">' . $sWxLink . '</td> <td align="left">' . $iVerifyState . '</td> <td align="left">' . $sIntroduction . '</td> <td align="left">' . $sTypeInfo . '</td> <td align="left">' . $sCooperateLevelInfo . '</td> <td align="left">' . $sCertifiedText . '</td> <td align="left">' . $iClickNumber . '</td> <td align="left">' . $iChoiceNumber . '</td> <td align="left">' . $iArticleNumber . '</td> <td align="left">' . $iZambiaNumber . '</td> <td align="left">' . $aCategory . '</td> <td align="left">' . $aCity . '</td> <td align="left">' . $aCricle . '</td> <td align="left">' . $aTag . '</td> </tr>'; } $str_explode .= '</table>'; $str_explode .= "</body></html>"; echo $str_explode; }
<?php require_once __DIR__ . '/../src/core.php'; CronRunner::run(__FILE__, function ($logger) { $userCount = Model_User::getCount(); $userCountActive = Model_User::getCountActive(); $mediaCount = []; $distArr = []; foreach (Media::getConstList() as $media) { $distArr[$media] = []; $mediaCount[$media] = Model_Media::getCount($media); } foreach (Media::getConstList() as $media) { $localDist = Model_MixedUserMedia::getRatingDistribution($media); foreach ($localDist->getGroupsKeys() as $key) { if (!isset($distArr[$media][$key])) { $distArr[$media][$key] = 0; } $distArr[$media][$key] += $localDist->getGroupSize($key); } } $globalsCache = ['user-count' => $userCount, 'user-count-active' => $userCountActive, 'media-count' => $mediaCount, 'rating-dist' => $distArr]; TextHelper::putJson(Config::$globalsCachePath, $globalsCache); });
/** * 导出 */ public function adexplodeAction() { $iAdID = intval($this->getParam('id')); $aAd = Model_Ad::getDetail($iAdID); //类别 $aCat = ''; if ($aAd['sCatID'] != '') { $rowCat = Model_Domain::getAll(array('where' => array('iAutoID IN' => $aAd['sCatID']))); if (count($rowCat) > 0) { foreach ($rowCat as $val) { if ($val['sName'] != '') { $aCat .= ',' . $val['sName']; } } } } $this->assign('aCat', $aCat); //城市 $aCityName = ''; if ($aAd['sCityID'] != '') { $rowCity = Model_City::getAll(array('where' => array('iCityID IN' => $aAd['sCityID']))); if (count($rowCity) > 0) { foreach ($rowCity as $val) { if ($val['sName'] != '') { $aCityName .= ',' . $val['sCityName']; } } } } $this->assign('aCityName', $aCityName); $iType = $aAd['iMediaType']; $iTypeName = Model_Media::$aType[$aAd['iMediaType']]; $this->assign('iTypeName', $iTypeName); if ($aAd['iAdType'] == '1') { $this->assign('iAdType', '软广'); } elseif ($aAd['iAdType'] == '2') { $this->assign('iAdType', '硬广'); } elseif ($aAd['iAdType'] == '3') { $this->assign('iAdType', '全部'); } if ($aAd['iStatus'] == '1') { $this->assign('iStatus', '待审核'); } elseif ($aAd['iStatus'] == '2') { $this->assign('iStatus', '审核通过'); } elseif ($aAd['iStatus'] == '3') { $this->assign('iStatus', '审核未通过'); } elseif ($aAd['iStatus'] == '4') { $this->assign('iStatus', '完成'); } elseif ($aAd['iStatus'] == '5') { $this->assign('iStatus', '未填写完成'); } $aUser = Model_User::getDetail($aAd['iUserID']); $this->assign('aUser', $aUser); $this->assign('aAd', $aAd); //资源广告内容 if ($aAd['iMediaType'] == Model_Media::TYPE_WEIXIN) { $rowAd = Model_AdWeixin::getDetail($aAd['iAdID']); $this->assign('type_weixin', Model_Media::TYPE_WEIXIN); $iPosID = $rowAd['iAdPos']; } elseif ($aAd['iMediaType'] == Model_Media::TYPE_FRIEND) { $rowAd = Model_AdFriend::getDetail($aAd['iAdID']); $this->assign('type_friend', Model_Media::TYPE_FRIEND); $iPosID = $rowAd['iAdPos']; } elseif ($aAd['iMediaType'] == Model_Media::TYPE_WEIBO) { $rowAd = Model_AdWeibo::getDetail($aAd['iAdID']); $this->assign('type_weibo', Model_Media::TYPE_WEIBO); $iPosID = $rowAd['iAdPos']; } elseif ($aAd['iMediaType'] == Model_Media::TYPE_NEWS) { $rowAd = Model_AdNews::getDetail($aAd['iAdID']); $this->assign('type_news', Model_Media::TYPE_NEWS); $iPosID = $rowAd['iAdPos']; } //广告位 $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' => '直发报价')); if ($aAd['iMediaType'] != '') { $iPos = $aTitle[$aAd['iMediaType']][$iPosID]; $this->assign('aPos', $iPos); } $this->assign('rowAd', $rowAd); $aAdMedia = Model_AdMedia::getAll(array('where' => array('iAdID' => $aAd['iAdID']))); foreach ($aAdMedia as $key => $val) { //资源 $aMedia = Model_Media::getDetail($val['iMediaID']); $aAdMedia[$key]['sMediaName'] = $aMedia['sMediaName']; //用户 $aUser = Model_User::getDetail($val['iUserID']); $aAdMedia[$key]['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' => '直发报价')); if ($aAd['iMediaType'] != '') { $iPos = $aTitle[$aAd['iMediaType']][$val['iPos']]; $aAdMedia[$key]['iPosName'] = $iPos; } //支付状态 if ($val['iPayStatus'] == '0') { $aAdMedia[$key]['iPayStatusName'] = '未支付'; } elseif ($val['iPayStatus'] == '1') { $aAdMedia[$key]['iPayStatusName'] = '已支付'; } //状态 if ($val['iStatus'] == '1') { $aAdMedia[$key]['iStatusName'] = '等待接单'; } elseif ($val['iStatus'] == '2') { $aAdMedia[$key]['iStatusName'] = '等待执行'; } elseif ($val['iStatus'] == '3') { $aAdMedia[$key]['iStatusName'] = '执行中'; } elseif ($val['iStatus'] == '4') { $aAdMedia[$key]['iStatusName'] = '已完成'; } elseif ($val['iStatus'] == '5') { $aAdMedia[$key]['iStatusName'] = '拒绝接单'; } } $this->assign('aAdMedia', $aAdMedia); 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> <td>用户名称</td> <td>' . $aUser['sRealName'] . '</td> </tr> <tr> <td>广告名称</td> <td>' . (isset($aAd['sAdName']) ? $aAd['sAdName'] : '') . '</td> </tr> <tr> <td>最小投放预算</td> <td>' . (isset($aAd['iPlanMinMoney']) ? $aAd['iPlanMinMoney'] : '') . '</td> </tr> <tr> <td>最大投放预算</td> <td>' . (isset($aAd['iPlanMaxMoney']) ? $aAd['iPlanMaxMoney'] : '') . '</td> </tr> <tr> <td>投放时间</td> <td>' . (isset($aAd['iPlanTime']) ? $aAd['iPlanTime'] : '') . '</td> </tr> <tr> <td>媒体类型</td> <td>' . $iTypeName . '</td> </tr> <tr> <td>广告类型</td> <td>' . $iAdType . '</td> </tr> <tr> <td>媒体分类</td> <td>' . $aCat . '</td> </tr> <tr> <td>所在城市</td> <td>' . $aCityName . '</td> </tr> <tr> <td>总价</td> <td>' . (isset($aAd['iTotalMoney']) ? $aAd['iTotalMoney'] : '') . '</td> </tr> <tr> <td>支付类型</td> <td>' . (isset($aAd['iPayStatus']) && $aAd['iPayStatus'] == '0' ? '未付款' : '已付款') . '</td> </tr>'; if ($aAd['iMediaType'] == Model_Media::TYPE_WEIXIN) { $str_explode .= '<tr> <td>广告位</td> <td>' . $aPos . '</td> </tr> <tr> <td>显示时间</td> <td>' . date('Y-m-d H:i:s', $rowAd['iShowTime']) . '</td> </tr> <tr> <td>导入URL</td> <td>' . $rowAd['sImportUrl'] . '</td> </tr> <tr> <td>上传Word</td> <td>' . $rowAd['sWordFile'] . '</td> </tr> <tr> <td>标题</td> <td>' . $rowAd['sTitle'] . '</td> </tr> <tr> <td>作者</td> <td>' . $rowAd['sAuthor'] . '</td> </tr> <tr> <td>封面图片</td> <td>' . (isset($rowAd['sCoverImg']) ? Util_Uri::getDFSViewURL($rowAd['sCoverImg'], 130, 130) : '') . '</td> </tr> <tr> <td>摘要</td> <td>' . $rowAd['sAbstract'] . '</td> </tr> <tr> <td>内容</td> <td>' . $rowAd['sContent'] . '</td> </tr> <tr> <td>原链接</td> <td>' . $rowAd['sOriginalUrl'] . '</td> </tr>'; } elseif ($aAd['iMediaType'] == Model_Media::TYPE_FRIEND) { $str_explode .= '<tr> <td>投放形式</td> <td>' . $aPos . '</td> </tr> <tr> <td>转发链接</td> <td>' . $rowAd['sForwardUrl'] . '</td> </tr> <tr> <td>转发文字</td> <td>' . $rowAd['sForwardText'] . '</td> </tr> <tr> <td>转发配图</td> <td>'; if ($rowAd['sForwardImg'] != '') { $arr = explode(',', $rowAd['sForwardImg']); if (count($arr) > 0) { foreach ($arr as $v) { $str_explode .= '<img src="' . Util_Uri::getDFSViewURL($v, 130, 130) . '" width="130" />'; } } else { $str_explode .= '<img src="' . Util_Uri::getDFSViewURL($rowAd['sOriginalUrl'], 130, 130) . '" width="130" />'; } } $str_explode .= '</td> </tr>'; } elseif ($aAd['iMediaType'] == Model_Media::TYPE_WEIBO) { $str_explode .= '<tr> <td>投放形式</td> <td>' . $aPos . '</td> </tr> <tr> <td>转发链接</td> <td>' . $rowAd['sForwardUrl'] . '</td> </tr> <tr> <td>转发文字</td> <td>' . $rowAd['sForwardText'] . '</td> </tr> <tr> <td>转发配图</td> <td>'; if ($rowAd['sForwardImg'] != '') { $arr = explode(',', $rowAd['sForwardImg']); if (count($arr) > 0) { foreach ($arr as $v) { $str_explode .= '<img src="' . Util_Uri::getDFSViewURL($v, 130, 130) . '" width="130" />'; } } else { $str_explode .= '<img src="' . Util_Uri::getDFSViewURL($rowAd['sForwardImg'], 130, 130) . '" width="130" />'; } } $str_explode .= '</td> </tr>'; } elseif ($aAd['iMediaType'] == Model_Media::TYPE_NEWS) { $str_explode .= '<tr> <td>投放形式</td> <td>' . $aPos . '</td> </tr> <tr> <td>标题</td> <td>' . $rowAd['sTitle'] . '</td> </tr> <tr> <td>内容</td> <td>' . $rowAd['sContent'] . '</td> </tr>'; } $str_explode .= '<tr> <td>状态</td> <td>' . $iStatus . '</td> </tr> <tr> <td>资源列表</td> <td> <table cellspacing="0" cellpadding="3" rules="rows" border="1" id="" style="border-style:None;width:100%;border-collapse:collapse;"> <tr> <td style="border-right: 1px solid #000000;border-bottom: 1px solid #000000;">#</td> <td style="border-right: 1px solid #000000;border-bottom: 1px solid #000000;">用户名称</td> <td style="border-right: 1px solid #000000;border-bottom: 1px solid #000000;">媒体名称</td> <td style="border-right: 1px solid #000000;border-bottom: 1px solid #000000;">广告位</td> <td style="border-right: 1px solid #000000;border-bottom: 1px solid #000000;">价格</td> <td style="border-right: 1px solid #000000;border-bottom: 1px solid #000000;">执行时间</td> <td style="border-right: 1px solid #000000;border-bottom: 1px solid #000000;">支付状态</td> <td style="border-bottom: 1px solid #000000;">状态</td> </tr>'; foreach ($aAdMedia as $keyAdMedia => $valAdMedia) { $iAutoID = $valAdMedia['iAutoID']; $sEmail = $valAdMedia['sEmail']; $sMediaName = $valAdMedia['sMediaName']; $iPosName = $valAdMedia['iPosName']; $iMoney = $valAdMedia['iMoney']; $iPlanTime = ''; if ($valAdMedia['iPlanTime'] != '' && $valAdMedia['iPlanTime'] > 0) { $iPlanTime = date('Y-m-d', $valAdMedia['iPlanTime']); } $iPayStatusName = $valAdMedia['iPayStatusName']; $iStatusName = $valAdMedia['iStatusName']; $str_explode .= '<tr> <td style="border-right: 1px solid #000000;border-bottom: 1px solid #000000;">' . $iAutoID . '</td> <td style="border-right: 1px solid #000000;border-bottom: 1px solid #000000;">' . $sEmail . '</td> <td style="border-right: 1px solid #000000;border-bottom: 1px solid #000000;">' . $sMediaName . '</td> <td style="border-right: 1px solid #000000;border-bottom: 1px solid #000000;">' . $iPosName . '</td> <td style="border-right: 1px solid #000000;border-bottom: 1px solid #000000;">' . $iMoney . '</td> <td style="border-right: 1px solid #000000;border-bottom: 1px solid #000000;">' . $iPlanTime . '</td> <td style="border-right: 1px solid #000000;border-bottom: 1px solid #000000;">' . $iPayStatusName . '</td> <td style="border-bottom: 1px solid #000000;">' . $iStatusName . '</td> </tr>'; } $str_explode .= '</table> </td> </tr> <tr> <td>更新时间</td> <td>' . date('Y-m-d H:i:s', $aAd['iUpdateTime']) . '</td> </tr> <tr> <td>创建时间</td> <td>' . date('Y-m-d H:i:s', $aAd['iCreateTime']) . '</td> </tr>'; $str_explode .= '</table>'; $str_explode .= "</body></html>"; echo $str_explode; }
/** * 用户修改 */ public function editAction() { if ($this->_request->isPost()) { $aUser = $this->_checkData('update'); if (empty($aUser)) { return null; } $aUser['iUserID'] = intval($this->getParam('iUserID')); $aOldUser = Model_User::getDetail($aUser['iUserID']); if (empty($aOldUser)) { return $this->showMsg('用户不存在!', false); } if ($aOldUser['sEmail'] != $aUser['sEmail'] && $aOldUser['iStatus'] > 0) { if (Model_User::getUserByEmail($aUser['sEmail'])) { return $this->showMsg('用户已经存在!', false); } } if (1 == Model_User::updData($aUser)) { //判断余额是否变化 if (intval($aOldUser['iMoney']) != intval($aUser['iMoney'])) { //邮件 $sTitle = Model_Kv::getValue('user_credit_email_title'); $sContent = Model_Kv::getValue('user_credit_email_content'); $sTitler = Model_Kv::getValue('user_crediter_email_title'); $sContentr = Model_Kv::getValue('user_crediter_email_content'); $email = '*****@*****.**'; $Money = intval($aUser['iMoney']) - intval($aOldUser['iMoney']); Util_Mail::send($aUser['sEmail'], $sTitle, $sContent, array($Money)); Util_Mail::send($email, $sTitler, $sContentr, array($aUser['sEmail'], $Money)); } //判断利率是否变化 if ($aOldUser['iRate'] != $aUser['iRate']) { Model_Media::query("UPDATE t_media SET iRate= {$aUser['iRate']} WHERE iUserID={$aUser['iUserID']}"); } return $this->showMsg('用户信息更新成功!', true); } else { return $this->showMsg('用户信息更新失败!', false); } } else { $iUserID = intval($this->getParam('id')); $aUser = Model_User::getDetail($iUserID); $this->assign('aUser', $aUser); $this->assign('aBusiness', Model_Domain::getPairDomain(Model_Domain::TYPE_CO_INDUSTRY)); //行业 } }
/** * 支付款项 */ 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' => '添加推广计划 - 支付款项')); } }
foreach (Media::getConstList() as $media) { foreach ($userContext->user->getMixedUserMedia($media) as $entry) { $mediaAge = time() - strtotime($entry->processed); if ($mediaAge > Config::$mediaQueueMinWait) { $mediaIds[] = TextHelper::serializeMediaId($entry); } } } $mediaQueue->enqueueMultiple(array_map(function ($mediaId) { return new QueueItem($mediaId); }, $mediaIds)); $logger->log('ok'); }); $mediaIds = []; foreach (Media::getConstList() as $media) { $entries = Model_Media::getOldest($media, 100); foreach ($entries as $entry) { $mediaAge = time() - strtotime($entry->processed); if ($mediaAge > Config::$mediaQueueMinWait) { $mediaIds[] = TextHelper::serializeMediaId($entry); } } } $mediaQueue->enqueueMultiple(array_map(function ($mediaId) { return new QueueItem($mediaId); }, $mediaIds)); #process media processQueue($mediaQueue, Config::$mediaPerCronRun, Config::$mediaQueueMaxAttempts, $logger, function ($key) use($mediaProcessors, $logger) { list($media, $malId) = TextHelper::deserializeMediaId($key); $logger->log('Processing %s #%d... ', Media::toString($media), $malId); #process the media
/** * 账号中心 */ public function accountAction() { $iType = max(1, (int) $this->getParam('type')); $iPage = max(1, intval($this->getParam('page'))); $aData = Model_Media::getList(array('iStatus > ' => 0, 'iUserID' => $this->aCurrUser['iUserID'], 'iMediaType' => $iType), $iPage); $this->assign('aData', $aData); $this->assign('iType', $iType); $this->setMeta('mcenter_page', array('sTitle' => '自媒体中心 - 财号中心')); }
/** * Creates a droplets from the given array * * @param array $droplet * @return array */ public static function create_from_array($droplets) { if (!count($droplets)) { return; } // Populate identities Model_Identity::get_identities($droplets); // Hash array with droplet_hash as key and index in droplets array that contain that hash $droplets_idx = array(); foreach ($droplets as $key => &$droplet) { if (!isset($droplet['id'])) { $hash = md5($droplet['identity_orig_id'] . $droplet['channel'] . $droplet['droplet_orig_id']); $droplet['droplet_hash'] = $hash; if (empty($droplets_idx[$hash])) { $droplets_idx[$hash] = array(); } $droplets_idx[$hash][] = $key; } } // Insert new drops $new_droplets = array(); if (!empty($droplets_idx)) { Swiftriver_Mutex::obtain(get_class(), 3600); // Find the drops that already exist by their droplet_hash $found_query = DB::select('droplet_hash', 'id')->from('droplets')->where('droplet_hash', 'IN', array_keys($droplets_idx)); $found = $found_query->execute()->as_array(); // Update the ids of existing drops found in the db and // remove them from droplets_idx to leave new drops $new_droplet_count = count($droplets_idx); foreach ($found as $hash) { foreach ($droplets_idx[$hash['droplet_hash']] as $key) { $droplets[$key]['id'] = $hash['id']; } $new_droplet_count--; unset($droplets_idx[$hash['droplet_hash']]); } if (!empty($droplets_idx)) { // Get a range of IDs to be used in inserting the new drops $base_id = Model_Droplet::get_ids($new_droplet_count); // Insert into the droplets table $query = DB::insert('droplets', array('id', 'channel', 'droplet_hash', 'droplet_orig_id', 'droplet_type', 'droplet_title', 'droplet_content', 'droplet_date_pub', 'droplet_date_add', 'identity_id', 'processing_status')); foreach ($droplets_idx as $hash => $keys) { foreach ($keys as $key) { $droplets[$key]['id'] = $base_id; } // PHP has reference issues with array so // we cannot copy the element we have but // refeference it in place as below $droplets[$keys[0]] // otherwise the element will be overwriten if we use a // copy. Sigh. $new_droplets[] = $droplets[$keys[0]]; $query->values(array('id' => $base_id++, 'channel' => $droplets[$keys[0]]['channel'], 'droplet_hash' => $droplets[$keys[0]]['droplet_hash'], 'droplet_orig_id' => $droplets[$keys[0]]['droplet_orig_id'], 'droplet_type' => $droplets[$keys[0]]['droplet_type'], 'droplet_title' => $droplets[$keys[0]]['droplet_title'], 'droplet_content' => $droplets[$keys[0]]['droplet_content'], 'droplet_date_pub' => $droplets[$keys[0]]['droplet_date_pub'], 'droplet_date_add' => gmdate("Y-m-d H:i:s", time()), 'identity_id' => $droplets[$keys[0]]['identity_id'], 'processing_status' => self::PROCESSING_STATUS_NEW)); } $query->execute(); } Swiftriver_Mutex::release(get_class()); } // Populate metadata IDs into the drops array Model_Tag::get_tags($droplets); Model_Link::get_links($droplets); Model_Place::get_places($droplets); Model_Media::get_media($droplets); // Populate the drop's metadata tables self::add_metadata($droplets); return array($droplets, $new_droplets); }
/** * 导出 */ 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; }