|
|
<?php
|
|
|
|
|
|
namespace Admin\Controller;
|
|
|
|
|
|
use Base\Tool\AggregateClient;
|
|
|
use User\Api\UserApi as UserApi;
|
|
|
use Think\Controller;
|
|
|
use Base\Service\PartnerService;
|
|
|
|
|
|
/**
|
|
|
* 工会信息
|
|
|
*/
|
|
|
class SocietyInfoController extends ThinkController
|
|
|
{
|
|
|
private $modelName = 'SocietyInfo';
|
|
|
private $admininfo = '';
|
|
|
private $level = [
|
|
|
1=>'S',
|
|
|
2=>'A',
|
|
|
3=>'B',
|
|
|
4=>'其他'
|
|
|
];
|
|
|
|
|
|
public function _initialize()
|
|
|
{
|
|
|
$this->admininfo = $_SESSION['onethink_admin']['user_auth'];
|
|
|
parent::_initialize();
|
|
|
}
|
|
|
//列表
|
|
|
public function lists()
|
|
|
{
|
|
|
$model = M($this->modelName, 'tab_');
|
|
|
$map = [];
|
|
|
if ($this->admininfo['username'] == "admin" || isMarketLeader()) {
|
|
|
// admin 和 市场总监可以看所有数据
|
|
|
} else {
|
|
|
// 其他用户只能看自己的
|
|
|
$map['create_account'] = $this->admininfo['username'];
|
|
|
}
|
|
|
|
|
|
if ($_REQUEST['text']||$_REQUEST['text']=='0') {
|
|
|
$map['_string'] = "province like '%{$_REQUEST['text']}%' or city like '%{$_REQUEST['text']}%'
|
|
|
or company_name like '%{$_REQUEST['text']}%' or register_capital like '%{$_REQUEST['text']}%' or functionary like '%{$_REQUEST['text']}%'
|
|
|
or phone like '%{$_REQUEST['text']}%' or wechat like '%{$_REQUEST['text']}%' or qq like '%{$_REQUEST['text']}%' or game_type like '%{$_REQUEST['text']}%'
|
|
|
or game_name like '%{$_REQUEST['text']}%' or join_platform like '%{$_REQUEST['text']}%' or promote_scale like '%{$_REQUEST['text']}%' or turnover= '{$_REQUEST['text']}'
|
|
|
or address like '%{$_REQUEST['text']}%' or league_info like '%{$_REQUEST['text']}%' or remark like '%{$_REQUEST['text']}%' or interface_person like '%{$_REQUEST['text']}%'";
|
|
|
}
|
|
|
|
|
|
$page = intval(I('get.p', 0));
|
|
|
$page = $page ? $page : 1; //默认显示第一页数据
|
|
|
$row = intval(I('row', 0));
|
|
|
$row = empty($row) ? 10 : $row;//每页条数
|
|
|
|
|
|
$is_export= false;
|
|
|
if (isset($_REQUEST['export']) && $_REQUEST['export']==1){
|
|
|
$is_export = true;
|
|
|
}
|
|
|
$config = M('config', 'sys_')->where([
|
|
|
'name' => 'SOCIETY_INFO_COMMUNITION_GAP'
|
|
|
])->find();
|
|
|
$gap = $config['value'];
|
|
|
|
|
|
if (I('province') && I('province') != '请选择省份') $map['province'] = I('province');
|
|
|
if (I('city') && I('city') != '请选择城市') $map['city'] = I('city');
|
|
|
if (I('game_type') && I('game_type') != '请选择游戏类型') $map['game_type'] = array("exp", "like '%".I('game_type')."%'");
|
|
|
if (trim(I('interface_person'))) $map['interface_person'] = I('interface_person');
|
|
|
if (I('time_gap', '') == 1) {
|
|
|
$map['communication_time'] = array('gt', time() - $gap * 86400);
|
|
|
}
|
|
|
if (I('time_gap', -1) == 0) {
|
|
|
$map['communication_time'] = array('elt', time() - $gap * 86400);
|
|
|
}
|
|
|
if (I('sociaty_level') && I('sociaty_level') != '0') $map['sociaty_level'] = I('sociaty_level');
|
|
|
//获取分页数据
|
|
|
$query = $model->where($map)->order("communication_time desc");
|
|
|
$count = $query->count();
|
|
|
if($is_export){
|
|
|
$parseData = $query->field("province, city, company_name, register_capital, functionary, phone, wechat, qq, game_type, game_name, join_platform, promote_scale,sociaty_level, turnover, address, league_info, is_potential, remark, interface_person, create_time, communication_time, create_account")
|
|
|
->where($map)
|
|
|
->order("communication_time desc")
|
|
|
->select();
|
|
|
foreach ($parseData as &$v) {
|
|
|
$v['sociaty_level'] = $this->level[$v['sociaty_level']];
|
|
|
if ($v['is_potential'] == 1) $v['is_potential'] = "是";
|
|
|
else $v['is_potential'] = "否";
|
|
|
$v['communication_time'] = date('Y-m-d H:i:s', $v['communication_time']);
|
|
|
$v['create_time'] = date('Y-m-d H:i:s', $v['create_time']);
|
|
|
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("communication_time desc")->field("*")->page($page,$row)->select();
|
|
|
// dump($societyInfos);die();
|
|
|
}
|
|
|
|
|
|
//分页
|
|
|
$parameter = I("get.");
|
|
|
$parameter['p'] = $page;
|
|
|
$parameter['row'] = $row;
|
|
|
$page = set_pagination($count, $row, $parameter);
|
|
|
if ($page) {
|
|
|
$this->assign('_page', $page);
|
|
|
}
|
|
|
|
|
|
foreach ($societyInfos as $k => &$v) {
|
|
|
|
|
|
$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']];
|
|
|
|
|
|
if (time() - $v['communication_time'] > $gap * 86400
|
|
|
&& $v['is_potential'] == 1
|
|
|
)
|
|
|
$v['is_gap_time'] = 1;
|
|
|
|
|
|
if($gap == 0 && $v['communication_time']!=$v['create_time']) {
|
|
|
$v['is_gap_time'] = 0;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$this->checkListOrCountAuthRestMap($map,[]);
|
|
|
|
|
|
if (IS_ROOT) {
|
|
|
$this->assign('timeset_check',true);
|
|
|
$this->assign('delset_check',true);
|
|
|
} else {
|
|
|
$this->assign('timeset_check',$this->checkRule("Admin/SocietyInfo/timeset" ,array('in','1,2')));
|
|
|
$this->assign('delset_check',$this->checkRule("Admin/SocietyInfo/delset" ,array('in','1,2')));
|
|
|
}
|
|
|
|
|
|
|
|
|
// $this->assign('time_gap', $config['value']);
|
|
|
$gameTypes = M('game_type', 'tab_')->field("id, type_name")->select();
|
|
|
$this->assign('game_types', $gameTypes);
|
|
|
$this->assign('listData', $societyInfos);
|
|
|
$this->assign('count', $count);
|
|
|
$this->meta_title = '公会信息登记表(说明:此功能是公会信息内容登记)';
|
|
|
$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'
|
|
|
])->find();
|
|
|
$num = $config['value'];
|
|
|
if (IS_POST) {
|
|
|
$num = I('num');
|
|
|
if ($num < 0) {
|
|
|
$this->error("时间设置不能小于0");
|
|
|
}
|
|
|
M('config', 'sys_')->where([
|
|
|
'name' => 'SOCIETY_INFO_COMMUNITION_GAP'
|
|
|
])->save([
|
|
|
'value' => $num
|
|
|
]);
|
|
|
$this->success("设置成功");
|
|
|
}
|
|
|
|
|
|
$this->assign('num', $num);
|
|
|
$this->display();
|
|
|
}
|
|
|
//审核列表
|
|
|
public function index()
|
|
|
{
|
|
|
$page = intval(I('get.p', 0));
|
|
|
$page = $page ? $page : 1; //默认显示第一页数据
|
|
|
$row = intval(I('row', 0));
|
|
|
$row = empty($row) ? 10 : $row;//每页条数
|
|
|
$p = $_REQUEST;
|
|
|
|
|
|
if(!IS_ROOT){
|
|
|
$this->OpAuthList= getModuleControllerAuth();
|
|
|
}
|
|
|
|
|
|
$map = [];
|
|
|
if (!empty(I('partner_name'))) {
|
|
|
$map['partner_name'] = ['like', '%' . I('partner_name') . '%'];
|
|
|
}
|
|
|
if (!empty($p['verify_type'])) {
|
|
|
if($p['verify_type'] == 1){
|
|
|
$map['partner_id'] = 0;
|
|
|
}else{
|
|
|
$map['partner_id'] = ["neq",0];
|
|
|
}
|
|
|
}
|
|
|
if (isset($p['verify_status'])) {
|
|
|
$map['verify_status'] = $p['verify_status'];
|
|
|
}
|
|
|
|
|
|
if (isset($_REQUEST['timestart']) && isset($_REQUEST['timeend'])) {
|
|
|
$time_start = strtotime($_REQUEST['timestart']);
|
|
|
$time_end = strtotime($_REQUEST['timeend'])+ 86399;
|
|
|
$map["create_time"] =['BETWEEN',[$time_start, $time_end]];
|
|
|
} elseif (isset($_REQUEST['timestart'])) {
|
|
|
$time_start = strtotime($_REQUEST['timestart']);
|
|
|
$map["create_time"] =['EGT',$time_start];
|
|
|
} elseif (isset($_REQUEST['timeend'])) {
|
|
|
$time_end = strtotime($_REQUEST['timeend'])+ 86399;
|
|
|
$map["create_time"] = ['ELT',$time_end];
|
|
|
}
|
|
|
$model = M("partner_verify", 'tab_');
|
|
|
$data = $model->where($map)->page($page,$row)->order("FIELD(verify_status,0,1,-1),create_time desc")->select();
|
|
|
foreach ($data as $k => &$v) {
|
|
|
$v['partner_info'] = json_decode($v['partner_info'],true);
|
|
|
if($v['partner_id'] == 0){
|
|
|
$v['verify_type'] = "新增";
|
|
|
}else{
|
|
|
$v['verify_type'] = "修改";
|
|
|
}
|
|
|
$v['partner_info']['company_type'] = $v['partner_info']['company_type'] == 2 ? '个人' : '公司';
|
|
|
|
|
|
$contract_start_time = $v['partner_info']['contract_start_time'] ? time_format($v['partner_info']['contract_start_time'], 'Y/m/d') : '-';
|
|
|
if($v['partner_info']['contract_start_time']){
|
|
|
$contract_end_time = $v['partner_info']['contract_end_time'] ? date('Y/m/d', $v['partner_info']['contract_end_time']) : '永久';
|
|
|
}else{
|
|
|
$contract_end_time = $v['partner_info']['contract_end_time'] ? time_format($v['partner_info']['contract_end_time'], 'Y/m/d') : '-';
|
|
|
}
|
|
|
$v['contract_time'] = $contract_start_time . '-' . $contract_end_time;
|
|
|
|
|
|
$validity_start_time = $v['partner_info']['validity_start_time'] ?
|
|
|
time_format($v['partner_info']['validity_start_time'], 'Y/m/d') : '-';
|
|
|
|
|
|
if($v['partner_info']['validity_start_time']){
|
|
|
$validity_end_time = $v['partner_info']['validity_end_time'] ? date('Y/m/d', $v['partner_info']['validity_end_time']) : '永久';
|
|
|
}else{
|
|
|
$validity_end_time = $v['partner_info']['validity_end_time'] ? time_format($v['partner_info']['validity_end_time'], 'Y/m/d') : '-';
|
|
|
}
|
|
|
$v['validity_time'] = $validity_start_time . '-' . $validity_end_time;
|
|
|
|
|
|
$create_time = date("Y-m-d H:i:s",$v["create_time"]);
|
|
|
|
|
|
$v['verify_log'] = json_decode($v['verify_log'], true);
|
|
|
$v["create"]= "{$v['verify_log']['create_user']} <br> {$v['verify_log']['create_time']}";
|
|
|
if(isset($v['verify_log']['verify_user'])){
|
|
|
if($v['verify_status'] == -1){
|
|
|
$ts = "审核拒绝";
|
|
|
}else{
|
|
|
$ts = "审核通过";
|
|
|
}
|
|
|
$v["verify"]= "{$ts}({$v['verify_log']['verify_user']}) <br> {$v['verify_log']['verify_time']}";
|
|
|
}else{
|
|
|
$v["verify"] = '--';
|
|
|
}
|
|
|
|
|
|
}
|
|
|
$count = $model->where($map)->count();
|
|
|
$page = set_pagination($count, $row);
|
|
|
if ($page) {
|
|
|
$this->assign('_page', $page);
|
|
|
}
|
|
|
$this->assign('menubtn',$this->menuAuth());
|
|
|
$this->assign('listData', $data);
|
|
|
$this->assign('count', $count);
|
|
|
$this->assign('VerifyStatus', D("PartnerVerify")->VerifyStatus);
|
|
|
$this->meta_title = '上游CP审核列表';
|
|
|
$this->display();
|
|
|
}
|
|
|
|
|
|
//添加
|
|
|
public function add()
|
|
|
{
|
|
|
$gameTypes = M('game_type', 'tab_')->field("id, type_name")->select();
|
|
|
$this->assign("game_types", $gameTypes);
|
|
|
$this->assign("interface_person", $this->admininfo['username']);
|
|
|
|
|
|
if ($_POST) {
|
|
|
$save = I("post.");
|
|
|
if (empty($save['province'])) {
|
|
|
$this->error("省份为必填项");
|
|
|
}
|
|
|
if (empty($save['city'])) {
|
|
|
$this->error("城市为必填项");
|
|
|
}
|
|
|
if (empty($save['company_name'])) {
|
|
|
$this->error("公司为必填项");
|
|
|
}
|
|
|
if (empty($save['game_types'])) {
|
|
|
$this->error("游戏类型为必填项");
|
|
|
}
|
|
|
if ($save['province'] == "请选择省份") $save['province'] = '';
|
|
|
if ($save['city'] == "请选择城市") $save['city'] = '';
|
|
|
foreach ($save['game_types'] as $v) {
|
|
|
$save['game_type'] .= $v . "/";
|
|
|
}
|
|
|
$save['game_type'] = trim($save['game_type'], '/');
|
|
|
|
|
|
$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 {
|
|
|
$this->meta_title = '新增公会信息';
|
|
|
$this->display();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//编辑
|
|
|
public function edit()
|
|
|
{
|
|
|
$model = M($this->modelName, 'tab_');
|
|
|
|
|
|
if ($_POST) {
|
|
|
$save = I("post.");
|
|
|
$id = $save['id'];
|
|
|
foreach ($save['game_types'] as $v) {
|
|
|
$save['game_type'] .= $v . "/";
|
|
|
}
|
|
|
if ($save['province'] == '请选择省份') {
|
|
|
$save['province'] = '';
|
|
|
$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['communication_time'] = time();
|
|
|
$save['update_time'] = time();
|
|
|
unset($save['id']);
|
|
|
|
|
|
$res = M('society_info', 'tab_')->where(['id' => $id])->save($save);
|
|
|
if ($res === false) {
|
|
|
$this->error('保存失败');
|
|
|
} else {
|
|
|
\Think\Log::actionLog('SocietyInfo/edit', 'SocietyInfo', $id);
|
|
|
addOperationLog(array(
|
|
|
"op_type"=>1,
|
|
|
"key"=>$id,
|
|
|
"url"=>U("SocietyInfo/edit",array("id"=>$id))
|
|
|
));
|
|
|
$this->success('保存成功', U('index'));
|
|
|
}
|
|
|
} else {
|
|
|
$id = intval(I('get.id', 0));
|
|
|
$map['id'] = $id;
|
|
|
$data = $model->find($id);
|
|
|
if (empty($data)) {
|
|
|
$this->error('数据异常', U('lists'));
|
|
|
}
|
|
|
$gameTypes = M('game_type', 'tab_')->field("id, type_name")->select();
|
|
|
$myGameTypes = explode('/', $data['game_type']);
|
|
|
foreach ($gameTypes as &$v) {
|
|
|
$v['check'] = 0;
|
|
|
foreach ($myGameTypes as $item) {
|
|
|
if ($item == $v['type_name']) {
|
|
|
$v['check'] = 1;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$this->assign("game_types", $gameTypes);
|
|
|
$this->assign('data', $data);
|
|
|
$this->meta_title = '编辑';
|
|
|
$this->display();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//查看
|
|
|
public function view()
|
|
|
{
|
|
|
$model = M($this->modelName, 'tab_');
|
|
|
|
|
|
|
|
|
$id = intval(I('get.id', 0));
|
|
|
$map['id'] = $id;
|
|
|
$data = $model->find($id);
|
|
|
if (empty($data)) {
|
|
|
$this->error('数据异常', U('lists'));
|
|
|
}
|
|
|
$gameTypes = M('game_type', 'tab_')->field("id, type_name")->select();
|
|
|
$myGameTypes = explode('/', $data['game_type']);
|
|
|
foreach ($gameTypes as &$v) {
|
|
|
$v['check'] = 0;
|
|
|
foreach ($myGameTypes as $item) {
|
|
|
if ($item == $v['type_name']) {
|
|
|
$v['check'] = 1;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$this->assign("game_types", $gameTypes);
|
|
|
$this->assign('data', $data);
|
|
|
$this->meta_title = '编辑';
|
|
|
$this->display();
|
|
|
}
|
|
|
|
|
|
//删除
|
|
|
public function del()
|
|
|
{
|
|
|
if (!empty($_POST['ids'])) {
|
|
|
if (!is_array($_POST['ids'])) {
|
|
|
$this->error('参数异常');
|
|
|
}
|
|
|
|
|
|
$id = implode(',', $_POST['ids']);
|
|
|
} else {
|
|
|
$id = intval(I('get.id', 0));
|
|
|
if ($id == 0) {
|
|
|
$this->error('参数异常');
|
|
|
}
|
|
|
}
|
|
|
$res = M($this->modelName, 'tab_')->delete($id);
|
|
|
if ($res === false) {
|
|
|
$this->error('删除失败');
|
|
|
}
|
|
|
addOperationLog(array(
|
|
|
"op_type"=>2,
|
|
|
"key"=>$id,
|
|
|
"url"=>U("Society/lists")
|
|
|
));
|
|
|
$this->success('删除成功', U('lists'));
|
|
|
}
|
|
|
|
|
|
//批量删除
|
|
|
public function del_check() {
|
|
|
if (!empty($_POST['ids'])) {
|
|
|
if (!is_array($_POST['ids'])) {
|
|
|
$this->ajaxReturn(['status'=>0,'info'=>'参数异常']);
|
|
|
// $this->error('参数异常');
|
|
|
}
|
|
|
|
|
|
$id = implode(',', $_POST['ids']);
|
|
|
} else {
|
|
|
$id = intval(I('get.id', 0));
|
|
|
if ($id == 0) {
|
|
|
$this->ajaxReturn(['status'=>0,'info'=>'参数异常']);
|
|
|
// $this->error('参数异常');
|
|
|
}
|
|
|
}
|
|
|
$res = M($this->modelName, 'tab_')->delete($id);
|
|
|
if ($res === false) {
|
|
|
// $this->error('删除失败');
|
|
|
$this->ajaxReturn(['status'=>0,'info'=>'删除失败']);
|
|
|
}
|
|
|
addOperationLog(array(
|
|
|
"op_type"=>2,
|
|
|
"key"=>$id,
|
|
|
"url"=>U("Society/lists")
|
|
|
));
|
|
|
|
|
|
$this->ajaxReturn(['status'=>1,'info'=>'删除成功']);
|
|
|
|
|
|
}
|
|
|
|
|
|
// 导入
|
|
|
public function excelImport() {
|
|
|
|
|
|
header("Content-Type:text/html;charset=utf-8");
|
|
|
$upload = new \Think\Upload();// 实例化上传类
|
|
|
$upload->maxSize = 3145728 ;// 设置附件上传大小
|
|
|
$upload->exts = array('xls', 'xlsx');// 设置附件上传类
|
|
|
$upload->rootPath = './Uploads/'; // 设置附件上传目录
|
|
|
$upload->savePath = 'excel/'; // 设置附件上传目录
|
|
|
// 上传文件
|
|
|
$info = $upload->uploadOne($_FILES['excelData']);
|
|
|
$filename = './Uploads/'.$info['savepath'].$info['savename'];
|
|
|
$exts = $info['ext'];
|
|
|
|
|
|
if(!$info) {// 上传错误提示错误信息
|
|
|
$this->ajaxReturn(['msg'=>$upload->getError(),"status"=>0]);
|
|
|
// $this->error($upload->getError());
|
|
|
}
|
|
|
// 上传成功
|
|
|
$datas = $this->parseExcelIn($filename, $exts);
|
|
|
$inserts = [];
|
|
|
foreach ($datas as $k => $v) {
|
|
|
$flag = 0;
|
|
|
foreach ($v as $p) {
|
|
|
if (!empty($p)) {
|
|
|
$flag = 1;
|
|
|
}
|
|
|
}
|
|
|
if ($flag == 0) continue;
|
|
|
if ($k == 1) continue;
|
|
|
$inserts[$k-2]['province'] = $v['A'] ?? '';
|
|
|
if (!$v['A']) {
|
|
|
$this->ajaxReturn(['msg'=>"省份不能为空".$k,"status"=>0]);
|
|
|
}
|
|
|
|
|
|
$inserts[$k-2]['city'] = $v['B'] ?? '';
|
|
|
if (!$v['B']) {
|
|
|
$this->ajaxReturn(['msg'=>"城市不能为空".$k,"status"=>0]);
|
|
|
}
|
|
|
|
|
|
$inserts[$k-2]['company_name'] = $v['C'] ?? '';
|
|
|
if (mb_strlen($inserts[$k-2]['company_name'], "utf-8") > 100) {
|
|
|
$this->ajaxReturn(['msg'=>"公司名太长".$k,"status"=>0]);
|
|
|
}
|
|
|
if (!$inserts[$k-2]['company_name']) {
|
|
|
$this->ajaxReturn(['msg'=>"公司不能为空".$k,"status"=>0]);
|
|
|
}
|
|
|
$inserts[$k-2]['register_capital'] = $v['D'] ?? '';
|
|
|
if (strlen($inserts[$k-2]['register_capital']) > 50) {
|
|
|
$this->ajaxReturn(['msg'=>"推荐人太长".$k,"status"=>0]);
|
|
|
}
|
|
|
$inserts[$k-2]['functionary'] = $v['E'] ?? '';
|
|
|
if (strlen($inserts[$k-2]['functionary']) > 50) {
|
|
|
$this->ajaxReturn(['msg'=>"负责人太长".$k,"status"=>0]);
|
|
|
}
|
|
|
$inserts[$k-2]['phone'] = $v['F'] ?? '';
|
|
|
if (strlen($inserts[$k-2]['phone']) > 50) {
|
|
|
$this->ajaxReturn(['msg'=>"手机号太长".$k,"status"=>0]);
|
|
|
}
|
|
|
$inserts[$k-2]['wechat'] = $v['G'] ?? '';
|
|
|
if (strlen($inserts[$k-2]['wechat']) > 50) {
|
|
|
$this->ajaxReturn(['msg'=>"微信号太长".$k,"status"=>0]);
|
|
|
}
|
|
|
$inserts[$k-2]['qq'] = $v['H'] ?? '';
|
|
|
if (strlen($inserts[$k-2]['qq']) > 50) {
|
|
|
$this->ajaxReturn(['msg'=>"qq号太长".$k,"status"=>0]);
|
|
|
}
|
|
|
$inserts[$k-2]['game_type'] = $v['I'] ?? '';
|
|
|
$inserts[$k-2]['game_name'] = $v['J'] ?? '';
|
|
|
if (strlen($inserts[$k-2]['game_name']) > 50) {
|
|
|
$this->ajaxReturn(['msg'=>"游戏名太长".$k,"status"=>0]);
|
|
|
}
|
|
|
$inserts[$k-2]['join_platform'] = $v['K'] ?? '';
|
|
|
if (strlen($inserts[$k-2]['join_platform']) > 50) {
|
|
|
$this->ajaxReturn(['msg'=>"合作平台太长".$k,"status"=>0]);
|
|
|
}
|
|
|
$inserts[$k-2]['promote_scale'] = $v['L'] ?? '';
|
|
|
if (strlen($inserts[$k-2]['promote_scale']) > 50) {
|
|
|
$this->ajaxReturn(['msg'=>"推广规模太长".$k,"status"=>0]);
|
|
|
}
|
|
|
|
|
|
$inserts[$k-2]['turnover'] = $v['M'] ?? '';
|
|
|
if (strlen($inserts[$k-2]['turnover']) > 50) {
|
|
|
$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['O'] ?? '';
|
|
|
if (mb_strlen($inserts[$k-2]['address'], 'utf-8') > 100) {
|
|
|
$this->ajaxReturn(['msg'=>"地址太长".$k,"status"=>0]);
|
|
|
}
|
|
|
$inserts[$k-2]['league_info'] = $v['P'] ?? '';
|
|
|
if (strlen($inserts[$k-2]['league_info']) > 100) {
|
|
|
$this->ajaxReturn(['msg'=>"联盟信息太长".$k,"status"=>0]);
|
|
|
}
|
|
|
if ($v['Q']) {
|
|
|
$inserts[$k-2]['is_potential'] = ($v['Q']=="是" ? 1 : 0);
|
|
|
} else {
|
|
|
$inserts[$k-2]['is_potential'] = 1;
|
|
|
}
|
|
|
|
|
|
$inserts[$k-2]['remark'] = $v['R'] ?? '';
|
|
|
if (strlen($inserts[$k-2]['remark']) > 100) {
|
|
|
$this->ajaxReturn(['msg'=>"备注太长".$k,"status"=>0]);
|
|
|
}
|
|
|
$inserts[$k-2]['interface_person'] = $v['S'] ?? '';
|
|
|
if (strlen($inserts[$k-2]['interface_person']) > 50) {
|
|
|
$this->ajaxReturn(['msg'=>"对接人太长".$k,"status"=>0]);
|
|
|
}
|
|
|
|
|
|
$inserts[$k-2]['create_time'] = time();
|
|
|
$inserts[$k-2]['update_time'] = time();
|
|
|
$inserts[$k-2]['communication_time'] = time();
|
|
|
$inserts[$k-2]['create_account'] = $this->admininfo['username'];
|
|
|
|
|
|
$gameTypes = explode('/', $v['I']);
|
|
|
foreach ($gameTypes as $gameType) {
|
|
|
if (!M('game_type', 'tab_')->where(["type_name" => $gameType])->find()) {
|
|
|
$this->ajaxReturn(['msg'=>"游戏类型有误:{$gameType}","status"=>0]);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
M('society_info', 'tab_')->addAll($inserts);
|
|
|
$this->ajaxReturn(['msg'=>"导入成功","status"=>1]);
|
|
|
// $this->success("导入成功");
|
|
|
}
|
|
|
|
|
|
private function parseExcelIn($filename, $exts) {
|
|
|
//导入PHPExcel类库,因为PHPExcel没有用命名空间,只能inport导入
|
|
|
//import("Org.Util.PHPExcel");
|
|
|
vendor("PHPExcel.PHPExcel");
|
|
|
//创建PHPExcel对象,注意,不能少了\
|
|
|
$PHPExcel=new \PHPExcel();
|
|
|
//如果excel文件后缀名为.xls,导入这个类
|
|
|
if($exts == 'xls'){
|
|
|
//import("Org.Util.PHPExcel.Reader.Excel5");
|
|
|
$PHPReader=new \PHPExcel_Reader_Excel5();
|
|
|
}else if($exts == 'xlsx'){
|
|
|
//import("Org.Util.PHPExcel.Reader.Excel2007");
|
|
|
$PHPReader=new \PHPExcel_Reader_Excel2007();
|
|
|
}
|
|
|
//载入文件
|
|
|
$PHPExcel=$PHPReader->load($filename);
|
|
|
//获取表中的第一个工作表,如果要获取第二个,把0改为1,依次类推
|
|
|
$currentSheet=$PHPExcel->getSheet(0);
|
|
|
//获取总列数
|
|
|
$allColumn=$currentSheet->getHighestColumn();
|
|
|
//获取总行数
|
|
|
$allRow=$currentSheet->getHighestRow();
|
|
|
//循环获取表中的数据,$currentRow表示当前行,从哪行开始读取数据,索引值从0开始
|
|
|
for($currentRow=1;$currentRow<=$allRow;$currentRow++){
|
|
|
//从哪列开始,A表示第一列
|
|
|
for($currentColumn='A';$currentColumn<=$allColumn;$currentColumn++){
|
|
|
//数据坐标
|
|
|
$address=$currentColumn.$currentRow;
|
|
|
//读取到的数据,保存到数组$arr中
|
|
|
$data[$currentRow][$currentColumn]=$currentSheet->getCell($address)->getValue();
|
|
|
if(is_object($data[$currentRow][$currentColumn])) $data[$currentRow][$currentColumn] = $data[$currentRow][$currentColumn]->__toString();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
}
|