|
|
|
|
<?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 = '';
|
|
|
|
|
|
|
|
|
|
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'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$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);
|
|
|
|
|
}
|
|
|
|
|
//获取分页数据
|
|
|
|
|
$query = $model->where($map)->order("id 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, turnover, address, league_info, is_potential, remark, interface_person, create_time, communication_time, create_account")
|
|
|
|
|
->where($map)
|
|
|
|
|
->select();
|
|
|
|
|
foreach ($parseData as &$v) {
|
|
|
|
|
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("id desc")->field("*")->page($page,$row)->select();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//分页
|
|
|
|
|
$parameter = I("get.");
|
|
|
|
|
$parameter['p'] = $page;
|
|
|
|
|
$parameter['row'] = $row;
|
|
|
|
|
$page = set_pagination($count, $row, $parameter);
|
|
|
|
|
if ($page) {
|
|
|
|
|
$this->assign('_page', $page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach ($societyInfos as &$v) {
|
|
|
|
|
if (time() - $v['communication_time'] > $gap * 86400)
|
|
|
|
|
$v['is_gap_time'] = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->checkListOrCountAuthRestMap($map,[]);
|
|
|
|
|
$this->assign('timeset_check',$this->checkRule("Admin/SocietyInfo/timeset" ,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['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 {
|
|
|
|
|
$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'] = '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$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 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 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->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'] ?? '';
|
|
|
|
|
$inserts[$k-2]['city'] = $v['B'] ?? '';
|
|
|
|
|
$inserts[$k-2]['company_name'] = $v['C'] ?? '';
|
|
|
|
|
if (strlen($inserts[$k-2]['company_name']) > 100) {
|
|
|
|
|
$this->error("公司名太长".$k);
|
|
|
|
|
}
|
|
|
|
|
if (!$inserts[$k-2]['company_name']) {
|
|
|
|
|
$this->error("公司不能为空".$k);
|
|
|
|
|
}
|
|
|
|
|
$inserts[$k-2]['register_capital'] = $v['D'] ?? '';
|
|
|
|
|
if (strlen($inserts[$k-2]['register_capital']) > 50) {
|
|
|
|
|
$this->error("推荐人太长".$k);
|
|
|
|
|
}
|
|
|
|
|
$inserts[$k-2]['functionary'] = $v['E'] ?? '';
|
|
|
|
|
if (strlen($inserts[$k-2]['functionary']) > 50) {
|
|
|
|
|
$this->error("负责人太长".$k);
|
|
|
|
|
}
|
|
|
|
|
$inserts[$k-2]['phone'] = $v['F'] ?? '';
|
|
|
|
|
if (strlen($inserts[$k-2]['phone']) > 50) {
|
|
|
|
|
$this->error("手机号太长".$k);
|
|
|
|
|
}
|
|
|
|
|
$inserts[$k-2]['wechat'] = $v['G'] ?? '';
|
|
|
|
|
if (strlen($inserts[$k-2]['wechat']) > 50) {
|
|
|
|
|
$this->error("微信号太长".$k);
|
|
|
|
|
}
|
|
|
|
|
$inserts[$k-2]['qq'] = $v['H'] ?? '';
|
|
|
|
|
if (strlen($inserts[$k-2]['qq']) > 50) {
|
|
|
|
|
$this->error("qq号太长".$k);
|
|
|
|
|
}
|
|
|
|
|
$inserts[$k-2]['game_type'] = $v['I'] ?? '';
|
|
|
|
|
$inserts[$k-2]['game_name'] = $v['J'] ?? '';
|
|
|
|
|
if (strlen($inserts[$k-2]['game_name']) > 50) {
|
|
|
|
|
$this->error("游戏名太长".$k);
|
|
|
|
|
}
|
|
|
|
|
$inserts[$k-2]['join_platform'] = $v['K'] ?? '';
|
|
|
|
|
if (strlen($inserts[$k-2]['join_platform']) > 50) {
|
|
|
|
|
$this->error("合作平台太长".$k);
|
|
|
|
|
}
|
|
|
|
|
$inserts[$k-2]['promote_scale'] = $v['L'] ?? '';
|
|
|
|
|
if (strlen($inserts[$k-2]['promote_scale']) > 50) {
|
|
|
|
|
$this->error("推广规模太长".$k);
|
|
|
|
|
}
|
|
|
|
|
$inserts[$k-2]['turnover'] = $v['M'] ?? '';
|
|
|
|
|
if (strlen($inserts[$k-2]['turnover']) > 50) {
|
|
|
|
|
$this->error("流水太长".$k);
|
|
|
|
|
}
|
|
|
|
|
$inserts[$k-2]['address'] = $v['N'] ?? '';
|
|
|
|
|
if (strlen($inserts[$k-2]['address']) > 100) {
|
|
|
|
|
$this->error("地址太长".$k);
|
|
|
|
|
}
|
|
|
|
|
$inserts[$k-2]['league_info'] = $v['O'] ?? '';
|
|
|
|
|
if (strlen($inserts[$k-2]['league_info']) > 100) {
|
|
|
|
|
$this->error("联盟信息太长".$k);
|
|
|
|
|
}
|
|
|
|
|
$inserts[$k-2]['is_potential'] = $v['P']=="是" ? 1 : 0;
|
|
|
|
|
$inserts[$k-2]['remark'] = $v['Q'] ?? '';
|
|
|
|
|
if (strlen($inserts[$k-2]['remark']) > 100) {
|
|
|
|
|
$this->error("备注太长".$k);
|
|
|
|
|
}
|
|
|
|
|
$inserts[$k-2]['interface_person'] = $v['R'] ?? '';
|
|
|
|
|
if (strlen($inserts[$k-2]['interface_person']) > 50) {
|
|
|
|
|
$this->error("对接人太长".$k);
|
|
|
|
|
}
|
|
|
|
|
$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->error("游戏类型有误:{$gameType}");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
M('society_info', 'tab_')->addAll($inserts);
|
|
|
|
|
$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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|