|
|
@ -114,7 +114,9 @@ class SocietyInfoController extends ThinkController
|
|
|
|
$v['num'] = $k+1+intval((I('get.p', 0)?I('get.p', 0):1)-1)*$row;
|
|
|
|
$v['num'] = $k+1+intval((I('get.p', 0)?I('get.p', 0):1)-1)*$row;
|
|
|
|
$v['sociaty_level_str'] = $this->level[$v['sociaty_level']];
|
|
|
|
$v['sociaty_level_str'] = $this->level[$v['sociaty_level']];
|
|
|
|
|
|
|
|
|
|
|
|
if (time() - $v['communication_time'] > $gap * 86400)
|
|
|
|
if (time() - $v['communication_time'] > $gap * 86400
|
|
|
|
|
|
|
|
&& $v['is_potential'] == 1
|
|
|
|
|
|
|
|
)
|
|
|
|
$v['is_gap_time'] = 1;
|
|
|
|
$v['is_gap_time'] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -299,9 +301,24 @@ class SocietyInfoController extends ThinkController
|
|
|
|
|
|
|
|
|
|
|
|
if ($_POST) {
|
|
|
|
if ($_POST) {
|
|
|
|
$save = I("post.");
|
|
|
|
$save = I("post.");
|
|
|
|
|
|
|
|
if (empty($save['province'])) {
|
|
|
|
|
|
|
|
$this->error("省份为必填项");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($save['city'])) {
|
|
|
|
|
|
|
|
$this->error("城市为必填项");
|
|
|
|
|
|
|
|
}
|
|
|
|
if (empty($save['company_name'])) {
|
|
|
|
if (empty($save['company_name'])) {
|
|
|
|
$this->error("公司为必填项");
|
|
|
|
$this->error("公司为必填项");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($save['game_types'])) {
|
|
|
|
|
|
|
|
$this->error("游戏类型为必填项");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($save['game_types'] as $v) {
|
|
|
|
|
|
|
|
$save['game_type'] .= $v . "/";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$save['game_type'] = trim($save['game_type'], '/');
|
|
|
|
|
|
|
|
// dump($save['game_type']);die();
|
|
|
|
if ($save['province'] == "请选择省份") $save['province'] = '';
|
|
|
|
if ($save['province'] == "请选择省份") $save['province'] = '';
|
|
|
|
if ($save['city'] == "请选择城市") $save['city'] = '';
|
|
|
|
if ($save['city'] == "请选择城市") $save['city'] = '';
|
|
|
|
$save['create_time'] = time();
|
|
|
|
$save['create_time'] = time();
|
|
|
@ -331,6 +348,15 @@ class SocietyInfoController extends ThinkController
|
|
|
|
$save['province'] = '';
|
|
|
|
$save['province'] = '';
|
|
|
|
$save['city'] = '';
|
|
|
|
$save['city'] = '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($save['city'])) {
|
|
|
|
|
|
|
|
$this->error("城市为必填项");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($save['company_name'])) {
|
|
|
|
|
|
|
|
$this->error("公司为必填项");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($save['game_type'])) {
|
|
|
|
|
|
|
|
$this->error("游戏类型为必填项");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$save['game_type'] = trim($save['game_type'], '/');
|
|
|
|
$save['game_type'] = trim($save['game_type'], '/');
|
|
|
|
$save['communication_time'] = time();
|
|
|
|
$save['communication_time'] = time();
|
|
|
@ -463,6 +489,7 @@ class SocietyInfoController extends ThinkController
|
|
|
|
|
|
|
|
|
|
|
|
// 导入
|
|
|
|
// 导入
|
|
|
|
public function excelImport() {
|
|
|
|
public function excelImport() {
|
|
|
|
|
|
|
|
|
|
|
|
header("Content-Type:text/html;charset=utf-8");
|
|
|
|
header("Content-Type:text/html;charset=utf-8");
|
|
|
|
$upload = new \Think\Upload();// 实例化上传类
|
|
|
|
$upload = new \Think\Upload();// 实例化上传类
|
|
|
|
$upload->maxSize = 3145728 ;// 设置附件上传大小
|
|
|
|
$upload->maxSize = 3145728 ;// 设置附件上传大小
|
|
|
@ -473,8 +500,10 @@ class SocietyInfoController extends ThinkController
|
|
|
|
$info = $upload->uploadOne($_FILES['excelData']);
|
|
|
|
$info = $upload->uploadOne($_FILES['excelData']);
|
|
|
|
$filename = './Uploads/'.$info['savepath'].$info['savename'];
|
|
|
|
$filename = './Uploads/'.$info['savepath'].$info['savename'];
|
|
|
|
$exts = $info['ext'];
|
|
|
|
$exts = $info['ext'];
|
|
|
|
|
|
|
|
|
|
|
|
if(!$info) {// 上传错误提示错误信息
|
|
|
|
if(!$info) {// 上传错误提示错误信息
|
|
|
|
$this->error($upload->getError());
|
|
|
|
$this->ajaxReturn(['msg'=>$upload->getError(),"status"=>0]);
|
|
|
|
|
|
|
|
// $this->error($upload->getError());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 上传成功
|
|
|
|
// 上传成功
|
|
|
|
$datas = $this->parseExcelIn($filename, $exts);
|
|
|
|
$datas = $this->parseExcelIn($filename, $exts);
|
|
|
@ -489,68 +518,83 @@ class SocietyInfoController extends ThinkController
|
|
|
|
if ($flag == 0) continue;
|
|
|
|
if ($flag == 0) continue;
|
|
|
|
if ($k == 1) continue;
|
|
|
|
if ($k == 1) continue;
|
|
|
|
$inserts[$k-2]['province'] = $v['A'] ?? '';
|
|
|
|
$inserts[$k-2]['province'] = $v['A'] ?? '';
|
|
|
|
|
|
|
|
if (!$v['A']) {
|
|
|
|
|
|
|
|
$this->ajaxReturn(['msg'=>"省份不能为空".$k,"status"=>0]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$inserts[$k-2]['city'] = $v['B'] ?? '';
|
|
|
|
$inserts[$k-2]['city'] = $v['B'] ?? '';
|
|
|
|
|
|
|
|
if (!$v['B']) {
|
|
|
|
|
|
|
|
$this->ajaxReturn(['msg'=>"城市不能为空".$k,"status"=>0]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$inserts[$k-2]['company_name'] = $v['C'] ?? '';
|
|
|
|
$inserts[$k-2]['company_name'] = $v['C'] ?? '';
|
|
|
|
if (mb_strlen($inserts[$k-2]['company_name'], "utf-8") > 100) {
|
|
|
|
if (mb_strlen($inserts[$k-2]['company_name'], "utf-8") > 100) {
|
|
|
|
$this->error("公司名太长".$k);
|
|
|
|
$this->ajaxReturn(['msg'=>"公司名太长".$k,"status"=>0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!$inserts[$k-2]['company_name']) {
|
|
|
|
if (!$inserts[$k-2]['company_name']) {
|
|
|
|
$this->error("公司不能为空".$k);
|
|
|
|
$this->ajaxReturn(['msg'=>"公司不能为空".$k,"status"=>0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$inserts[$k-2]['register_capital'] = $v['D'] ?? '';
|
|
|
|
$inserts[$k-2]['register_capital'] = $v['D'] ?? '';
|
|
|
|
if (strlen($inserts[$k-2]['register_capital']) > 50) {
|
|
|
|
if (strlen($inserts[$k-2]['register_capital']) > 50) {
|
|
|
|
$this->error("推荐人太长".$k);
|
|
|
|
$this->ajaxReturn(['msg'=>"推荐人太长".$k,"status"=>0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$inserts[$k-2]['functionary'] = $v['E'] ?? '';
|
|
|
|
$inserts[$k-2]['functionary'] = $v['E'] ?? '';
|
|
|
|
if (strlen($inserts[$k-2]['functionary']) > 50) {
|
|
|
|
if (strlen($inserts[$k-2]['functionary']) > 50) {
|
|
|
|
$this->error("负责人太长".$k);
|
|
|
|
$this->ajaxReturn(['msg'=>"负责人太长".$k,"status"=>0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$inserts[$k-2]['phone'] = $v['F'] ?? '';
|
|
|
|
$inserts[$k-2]['phone'] = $v['F'] ?? '';
|
|
|
|
if (strlen($inserts[$k-2]['phone']) > 50) {
|
|
|
|
if (strlen($inserts[$k-2]['phone']) > 50) {
|
|
|
|
$this->error("手机号太长".$k);
|
|
|
|
$this->ajaxReturn(['msg'=>"手机号太长".$k,"status"=>0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$inserts[$k-2]['wechat'] = $v['G'] ?? '';
|
|
|
|
$inserts[$k-2]['wechat'] = $v['G'] ?? '';
|
|
|
|
if (strlen($inserts[$k-2]['wechat']) > 50) {
|
|
|
|
if (strlen($inserts[$k-2]['wechat']) > 50) {
|
|
|
|
$this->error("微信号太长".$k);
|
|
|
|
$this->ajaxReturn(['msg'=>"微信号太长".$k,"status"=>0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$inserts[$k-2]['qq'] = $v['H'] ?? '';
|
|
|
|
$inserts[$k-2]['qq'] = $v['H'] ?? '';
|
|
|
|
if (strlen($inserts[$k-2]['qq']) > 50) {
|
|
|
|
if (strlen($inserts[$k-2]['qq']) > 50) {
|
|
|
|
$this->error("qq号太长".$k);
|
|
|
|
$this->ajaxReturn(['msg'=>"qq号太长".$k,"status"=>0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$inserts[$k-2]['game_type'] = $v['I'] ?? '';
|
|
|
|
$inserts[$k-2]['game_type'] = $v['I'] ?? '';
|
|
|
|
$inserts[$k-2]['game_name'] = $v['J'] ?? '';
|
|
|
|
$inserts[$k-2]['game_name'] = $v['J'] ?? '';
|
|
|
|
if (strlen($inserts[$k-2]['game_name']) > 50) {
|
|
|
|
if (strlen($inserts[$k-2]['game_name']) > 50) {
|
|
|
|
$this->error("游戏名太长".$k);
|
|
|
|
$this->ajaxReturn(['msg'=>"游戏名太长".$k,"status"=>0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$inserts[$k-2]['join_platform'] = $v['K'] ?? '';
|
|
|
|
$inserts[$k-2]['join_platform'] = $v['K'] ?? '';
|
|
|
|
if (strlen($inserts[$k-2]['join_platform']) > 50) {
|
|
|
|
if (strlen($inserts[$k-2]['join_platform']) > 50) {
|
|
|
|
$this->error("合作平台太长".$k);
|
|
|
|
$this->ajaxReturn(['msg'=>"合作平台太长".$k,"status"=>0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$inserts[$k-2]['promote_scale'] = $v['L'] ?? '';
|
|
|
|
$inserts[$k-2]['promote_scale'] = $v['L'] ?? '';
|
|
|
|
if (strlen($inserts[$k-2]['promote_scale']) > 50) {
|
|
|
|
if (strlen($inserts[$k-2]['promote_scale']) > 50) {
|
|
|
|
$this->error("推广规模太长".$k);
|
|
|
|
$this->ajaxReturn(['msg'=>"推广规模太长".$k,"status"=>0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$inserts[$k-2]['turnover'] = $v['M'] ?? '';
|
|
|
|
$inserts[$k-2]['turnover'] = $v['M'] ?? '';
|
|
|
|
if (strlen($inserts[$k-2]['turnover']) > 50) {
|
|
|
|
if (strlen($inserts[$k-2]['turnover']) > 50) {
|
|
|
|
$this->error("流水太长".$k);
|
|
|
|
$this->ajaxReturn(['msg'=>"公会等级".$k,"status"=>0]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$inserts[$k-2]['turnover'] = $v['N'] ?? '';
|
|
|
|
|
|
|
|
if (strlen($inserts[$k-2]['turnover']) > 50) {
|
|
|
|
|
|
|
|
$this->ajaxReturn(['msg'=>"流水太长".$k,"status"=>0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$inserts[$k-2]['address'] = $v['N'] ?? '';
|
|
|
|
$inserts[$k-2]['address'] = $v['O'] ?? '';
|
|
|
|
if (mb_strlen($inserts[$k-2]['address'], 'utf-8') > 100) {
|
|
|
|
if (mb_strlen($inserts[$k-2]['address'], 'utf-8') > 100) {
|
|
|
|
$this->error("地址太长".$k);
|
|
|
|
$this->ajaxReturn(['msg'=>"地址太长".$k,"status"=>0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$inserts[$k-2]['league_info'] = $v['O'] ?? '';
|
|
|
|
$inserts[$k-2]['league_info'] = $v['P'] ?? '';
|
|
|
|
if (strlen($inserts[$k-2]['league_info']) > 100) {
|
|
|
|
if (strlen($inserts[$k-2]['league_info']) > 100) {
|
|
|
|
$this->error("联盟信息太长".$k);
|
|
|
|
$this->ajaxReturn(['msg'=>"联盟信息太长".$k,"status"=>0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$inserts[$k-2]['is_potential'] = $v['P']=="是" ? 1 : 0;
|
|
|
|
$inserts[$k-2]['is_potential'] = $v['Q']=="是" ? 1 : 0;
|
|
|
|
$inserts[$k-2]['remark'] = $v['Q'] ?? '';
|
|
|
|
$inserts[$k-2]['remark'] = $v['R'] ?? '';
|
|
|
|
if (strlen($inserts[$k-2]['remark']) > 100) {
|
|
|
|
if (strlen($inserts[$k-2]['remark']) > 100) {
|
|
|
|
$this->error("备注太长".$k);
|
|
|
|
$this->ajaxReturn(['msg'=>"备注太长".$k,"status"=>0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$inserts[$k-2]['interface_person'] = $v['R'] ?? '';
|
|
|
|
$inserts[$k-2]['interface_person'] = $v['S'] ?? '';
|
|
|
|
if (strlen($inserts[$k-2]['interface_person']) > 50) {
|
|
|
|
if (strlen($inserts[$k-2]['interface_person']) > 50) {
|
|
|
|
$this->error("对接人太长".$k);
|
|
|
|
$this->ajaxReturn(['msg'=>"对接人太长".$k,"status"=>0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$inserts[$k-2]['create_time'] = time();
|
|
|
|
$inserts[$k-2]['create_time'] = time();
|
|
|
|
$inserts[$k-2]['update_time'] = time();
|
|
|
|
$inserts[$k-2]['update_time'] = time();
|
|
|
|
$inserts[$k-2]['communication_time'] = time();
|
|
|
|
$inserts[$k-2]['communication_time'] = time();
|
|
|
@ -559,13 +603,14 @@ class SocietyInfoController extends ThinkController
|
|
|
|
$gameTypes = explode('/', $v['I']);
|
|
|
|
$gameTypes = explode('/', $v['I']);
|
|
|
|
foreach ($gameTypes as $gameType) {
|
|
|
|
foreach ($gameTypes as $gameType) {
|
|
|
|
if (!M('game_type', 'tab_')->where(["type_name" => $gameType])->find()) {
|
|
|
|
if (!M('game_type', 'tab_')->where(["type_name" => $gameType])->find()) {
|
|
|
|
$this->error("游戏类型有误:{$gameType}");
|
|
|
|
$this->ajaxReturn(['msg'=>"游戏类型有误:{$gameType}","status"=>0]);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
M('society_info', 'tab_')->addAll($inserts);
|
|
|
|
M('society_info', 'tab_')->addAll($inserts);
|
|
|
|
$this->success("导入成功");
|
|
|
|
$this->ajaxReturn(['msg'=>"导入成功","status"=>1]);
|
|
|
|
|
|
|
|
// $this->success("导入成功");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private function parseExcelIn($filename, $exts) {
|
|
|
|
private function parseExcelIn($filename, $exts) {
|
|
|
@ -575,13 +620,13 @@ class SocietyInfoController extends ThinkController
|
|
|
|
//创建PHPExcel对象,注意,不能少了\
|
|
|
|
//创建PHPExcel对象,注意,不能少了\
|
|
|
|
$PHPExcel=new \PHPExcel();
|
|
|
|
$PHPExcel=new \PHPExcel();
|
|
|
|
//如果excel文件后缀名为.xls,导入这个类
|
|
|
|
//如果excel文件后缀名为.xls,导入这个类
|
|
|
|
if($exts == 'xls'){
|
|
|
|
// if($exts == 'xls'){
|
|
|
|
//import("Org.Util.PHPExcel.Reader.Excel5");
|
|
|
|
//import("Org.Util.PHPExcel.Reader.Excel5");
|
|
|
|
$PHPReader=new \PHPExcel_Reader_Excel5();
|
|
|
|
$PHPReader=new \PHPExcel_Reader_Excel5();
|
|
|
|
}else if($exts == 'xlsx'){
|
|
|
|
// }else if($exts == 'xlsx'){
|
|
|
|
//import("Org.Util.PHPExcel.Reader.Excel2007");
|
|
|
|
// //import("Org.Util.PHPExcel.Reader.Excel2007");
|
|
|
|
$PHPReader=new \PHPExcel_Reader_Excel2007();
|
|
|
|
// $PHPReader=new \PHPExcel_Reader_Excel2007();
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
//载入文件
|
|
|
|
//载入文件
|
|
|
|
$PHPExcel=$PHPReader->load($filename);
|
|
|
|
$PHPExcel=$PHPReader->load($filename);
|
|
|
|
//获取表中的第一个工作表,如果要获取第二个,把0改为1,依次类推
|
|
|
|
//获取表中的第一个工作表,如果要获取第二个,把0改为1,依次类推
|
|
|
@ -606,4 +651,32 @@ class SocietyInfoController extends ThinkController
|
|
|
|
return $data;
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//模板导出
|
|
|
|
|
|
|
|
public function downloadSocial()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
header("Content-type: text/html; charset=utf-8");
|
|
|
|
|
|
|
|
error_reporting(E_ALL);
|
|
|
|
|
|
|
|
ini_set('display_errors', TRUE);
|
|
|
|
|
|
|
|
ini_set('display_startup_errors', TRUE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Vendor("PHPExcel.PHPExcel");
|
|
|
|
|
|
|
|
$objPHPExcel = new \PHPExcel();
|
|
|
|
|
|
|
|
$objReader = \PHPExcel_IOFactory::createReader('Excel2007');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//设置模板文件
|
|
|
|
|
|
|
|
$objPHPExcel = $objReader->load("Public/Admin/excel/social_template.xls");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$fileName = "公会信息模板";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ob_end_clean();//清除缓冲区,避免乱码
|
|
|
|
|
|
|
|
header('pragma:public');
|
|
|
|
|
|
|
|
header('Content-type:application/vnd.ms-excel;charset=utf-8;name="' . $fileName .'".xls');
|
|
|
|
|
|
|
|
header("Content-Disposition:attachment;filename={$fileName}.xls");//attachment新窗口打印inline本窗口打印
|
|
|
|
|
|
|
|
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
|
|
|
|
|
|
|
$objWriter->save('php://output');
|
|
|
|
|
|
|
|
exit;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|