diff --git a/Application/Admin/Controller/SocietyInfoController.class.php b/Application/Admin/Controller/SocietyInfoController.class.php index f9dd572d5..c92fb18ba 100644 --- a/Application/Admin/Controller/SocietyInfoController.class.php +++ b/Application/Admin/Controller/SocietyInfoController.class.php @@ -13,8 +13,7 @@ use Base\Service\PartnerService; class SocietyInfoController extends ThinkController { private $modelName = 'SocietyInfo'; - public $OpAuthList=[]; - public $aggregatePackageName = []; + private $admininfo = ''; public function _initialize() { @@ -61,13 +60,19 @@ class SocietyInfoController extends ThinkController $query = $model->where($map)->order("id desc"); $count = $query->count(); if($is_export){ - $parseData = $query->field("*")->select(); - $this->assign('listData', $parseData); - $GetData = $_GET; - unset($GetData['export']); - addOperationLog(['op_type'=>3,'key'=>getNowDate(),'url'=>U(CONTROLLER_NAME.'/'.ACTION_NAME,$GetData),'menu'=>"推广-公会信息-导出"]); - $this->display("export"); - die(); + $parseData = $query->field("province, city, company_name, register_capital, functionary, phone, wechat, qq, game_type, game_name, join_platform, promote_scale, turnover, address, league_info, is_potential, remark, interface_person, create_time, communication_time, create_account")->select(); + foreach ($parseData as &$v) { + if ($v['is_potential'] == 1) $v['is_potential'] = "是"; + else $v['is_potential'] = "否"; + unset($v['id']); + unset($v['game_id']); + unset($v['update_time']); + } + addOperationLog(['op_type'=>3,'key'=>getNowDate(),'url'=>U(CONTROLLER_NAME.'/'.ACTION_NAME, I('get.*')),'menu'=>"推广-公会信息-导出"]); + $head = ["省份", "城市", "公司", "注册资本", "负责人", "电话", "微信", "QQ", "游戏类型", "所做游戏", + "合作平台", "推广规模", "流水", "地址", "联盟信息", "是否为意向客户", "备注信息", "对接人", "录入时间", "最后沟通时间", "录入员"]; + $this->export($head, $parseData, "公会信息-".date('Ymd')); + return ; } else { $societyInfos = $model->where($map)->order("id desc")->field("*")->page($page,$row)->select(); } @@ -97,7 +102,40 @@ class SocietyInfoController extends ThinkController $this->display(); } - // + // 导出 + public function export($head, $body, $filename, $title='') { + Vendor("PHPExcel.PHPExcel"); + $objPHPExcel = new \PHPExcel(); + $startRow = 1; //从第一行开始 + $i='A'; + foreach($head as $item){ + $objPHPExcel->setActiveSheetIndex(0)->setCellValue($i.$startRow, $item); + $i++; + } + + //主体数据 + foreach($body as $key=>$value){ + $startRow++; + $index='A'; + foreach($value as $k=>$v){ + $objPHPExcel->getActiveSheet()->getStyle($index.$startRow)->getNumberFormat()->setFormatCode("@"); //文本格式 + $objPHPExcel->setActiveSheetIndex(0)->setCellValue($index.$startRow, $v); + $index++; + } + } + if ($title) { + $objPHPExcel->getActiveSheet()->setTitle($title); + } + $objPHPExcel->setActiveSheetIndex(0); + header('Content-Type: application/vnd.ms-excel'); + header('Content-Disposition: attachment;filename="'.$filename.'.xlsx"'); + header('Cache-Control: max-age=0'); + $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); + ob_end_clean(); + $objWriter->save('php://output'); + } + + // 时间间隔设置 public function timeset() { $config = M('config', 'sys_')->where([ 'name' => 'SOCIETY_INFO_COMMUNITION_GAP' @@ -223,9 +261,15 @@ class SocietyInfoController extends ThinkController if ($_POST) { $save = I("post."); + if (empty($save['company_name'])) { + $this->error("公司为必填项"); + } + if ($save['province'] == "请选择省份") $save['province'] = ''; + if ($save['city'] == "请选择城市") $save['city'] = ''; $save['create_time'] = time(); $save['update_time'] = time(); $save['communication_time'] = time(); + $save['create_account'] = $this->admininfo['username']; M('society_info', 'tab_')->add($save); $this->success('保存成功', U('lists')); } else { @@ -333,34 +377,38 @@ class SocietyInfoController extends ThinkController $datas = $this->parseExcelIn($filename, $exts); $inserts = []; foreach ($datas as $k => $v) { - foreach ($v as $p) { + /*foreach ($v as $p) { if (!$p) { $this->error("数据不能为空"); } - } + }*/ if ($k == 1) continue; - $inserts[$k-2]['province'] = $v['A']; - $inserts[$k-2]['city'] = $v['B']; - $inserts[$k-2]['company_name'] = $v['C']; - $inserts[$k-2]['register_capital'] = $v['D']; - $inserts[$k-2]['functionary'] = $v['E']; - $inserts[$k-2]['phone'] = $v['F']; - $inserts[$k-2]['wechat'] = $v['G']; - $inserts[$k-2]['qq'] = $v['H']; - $inserts[$k-2]['game_type'] = $v['I']; - $inserts[$k-2]['game_name'] = $v['J']; - $inserts[$k-2]['join_platform'] = $v['K']; - $inserts[$k-2]['promote_scale'] = $v['L']; - $inserts[$k-2]['turnover'] = $v['M']; - $inserts[$k-2]['address'] = $v['N']; - $inserts[$k-2]['league_info'] = $v['O']; + $inserts[$k-2]['province'] = $v['A'] ?? ''; + $inserts[$k-2]['city'] = $v['B'] ?? ''; + $inserts[$k-2]['company_name'] = $v['C'] ?? ''; + if (!$inserts[$k-2]['company_name']) { + $this->error("公司不能为空"); + } + $inserts[$k-2]['register_capital'] = $v['D'] ?? ''; + $inserts[$k-2]['functionary'] = $v['E'] ?? ''; + $inserts[$k-2]['phone'] = $v['F'] ?? ''; + $inserts[$k-2]['wechat'] = $v['G'] ?? ''; + $inserts[$k-2]['qq'] = $v['H'] ?? ''; + $inserts[$k-2]['game_type'] = $v['I'] ?? ''; + $inserts[$k-2]['game_name'] = $v['J'] ?? ''; + $inserts[$k-2]['join_platform'] = $v['K'] ?? ''; + $inserts[$k-2]['promote_scale'] = $v['L'] ?? ''; + $inserts[$k-2]['turnover'] = $v['M'] ?? ''; + $inserts[$k-2]['address'] = $v['N'] ?? ''; + $inserts[$k-2]['league_info'] = $v['O'] ?? ''; $inserts[$k-2]['is_potential'] = $v['P']=="是" ? 1 : 0; - $inserts[$k-2]['remark'] = $v['Q']; - $inserts[$k-2]['interface_person'] = $v['R']; + $inserts[$k-2]['remark'] = $v['Q'] ?? ''; + $inserts[$k-2]['interface_person'] = $v['R'] ?? ''; $inserts[$k-2]['create_time'] = time(); $inserts[$k-2]['update_time'] = time(); $inserts[$k-2]['communication_time'] = time(); + $save['create_account'] = $this->admininfo['username']; $gameTypes = explode('/', $v['I']); foreach ($gameTypes as $gameType) { diff --git a/Application/Admin/View/SocietyInfo/add.html b/Application/Admin/View/SocietyInfo/add.html index 1cb0425a1..ed8c389bd 100644 --- a/Application/Admin/View/SocietyInfo/add.html +++ b/Application/Admin/View/SocietyInfo/add.html @@ -48,7 +48,7 @@
省份 | -城市 | -公司 | -注册资本 | -负责人 | -电话 | -微信 | -游戏类型 | -所做游戏 | -合作平台 | -推广规模 | -流水 | -地址 | -联盟信息 | -是否为意向客户 | -备注信息 | -对接人 | -录入时间 | -最后沟通时间 | -aOh! 暂时还没有内容! | -
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
{$data.province} | -{$data.city} | -{$data.company_name} | -{$data.register_capital} | -{$data.functionary} | -{$data.phone} | -{$data.wechat} | -{$data.qq} | -{$data.game_type} | -{$data.game_name} | -{$data.join_platform} | -{$data.promote_scale} | -{$data.turnover} | -{$data.address} | -{$data.league_info} | -{$data.is_potential} | -{$data.remark} | -{$data.interface_person} | -{$data.create_time|date='Y-m-d H:i:s', ###} | -{$data.communication_time|date='Y-m-d H:i:s', ###} | -
文件格式参考:请严格按照此格式,文件的第一行必须是字段名,且字段名不允许修改,游戏类型目前仅支持:国战、宫斗、返利服、商战、传奇、仙侠、卡牌、策略如果游戏为多个类型,请用“/”隔开,如:策略/卡牌
+{$data.turnover} | {$data.address} | {$data.league_info} | -{$data.is_potential} | +
+ |
{$data.remark} | {$data.interface_person} | {$data.create_time|date='Y-m-d H:i:s', ###} | @@ -188,6 +192,60 @@