Ejemplo n.º 1
0
    /**
     * 导出资源数据
     */
    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;
    }