diff --git a/Application/Admin/Controller/SocietyInfoController.class.php b/Application/Admin/Controller/SocietyInfoController.class.php
index 223e026fe..44ba58a20 100644
--- a/Application/Admin/Controller/SocietyInfoController.class.php
+++ b/Application/Admin/Controller/SocietyInfoController.class.php
@@ -13,8 +13,6 @@ use Base\Service\PartnerService;
class SocietyInfoController extends ThinkController
{
private $modelName = 'SocietyInfo';
- public $OpAuthList=[];
- public $aggregatePackageName = [];
public function _initialize()
{
@@ -61,17 +59,19 @@ class SocietyInfoController extends ThinkController
$query = $model->where($map)->order("id desc");
$count = $query->count();
if($is_export){
- $parseData = $query->field("*")->select();
+ $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']);
}
- $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();
+ 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();
}
@@ -101,7 +101,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'
@@ -227,6 +260,9 @@ 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();
@@ -340,31 +376,34 @@ 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();
diff --git a/Application/Admin/View/SocietyInfo/export.html b/Application/Admin/View/SocietyInfo/export.html
deleted file mode 100644
index 92cfa476b..000000000
--- a/Application/Admin/View/SocietyInfo/export.html
+++ /dev/null
@@ -1,147 +0,0 @@
-{$meta_title}
-
-
-
-
-
-
-
-
-
-
- 省份
- 城市
- 公司
- 注册资本
- 负责人
- 电话
- 微信
- QQ
- 游戏类型
- 所做游戏
- 合作平台
- 推广规模
- 流水
- 地址
- 联盟信息
- 是否为意向客户
- 备注信息
- 对接人
- 录入时间
- 最后沟通时间
- 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', ###}
-