推广配置

master
sunke 5 years ago
parent 79f9801351
commit b9ddc1aafb

@ -289,19 +289,45 @@ class GameController extends ThinkController
}
}
public function delSociatyGames() {
$res = ['code' => 10000];
$id = $_REQUEST['id'];
$delRest = M('sociaty_games','tab_')->where(['id'=>$id])->delete();
if($delRest) {
$res['code'] = 10001;
$this->ajaxReturn($res);
}
}
public function edit($id = null)
{
if (IS_POST) {
if(!empty($_REQUEST['promote_data'])) {
$promote_data = json_decode($_REQUEST['promote_data'],TRUE);
if(!empty($_REQUEST['apply_auth'])) {
$gameData['apply_auth'] = $_REQUEST['apply_auth'];
$game_appid = $_REQUEST['game_appid'];
$gameId = M('game','tab_')->where(['game_appid' => $game_appid])->getField('id');
$gameInfo = M('game','tab_')->field('game_name,game_status')->where(['id'=>$gameId])->select();
$dataList = array();
foreach($promote_data as $key => $promoteInfo) {
$dataList[] = ['promote_id' => intval($promoteInfo['value']),'game_id' => intval($gameId),'status'=>$gameInfo[0]['game_status'],'create_time'=>time()];
M('game','tab_')->where(['id'=>$gameId])->save($gameData);
if($_REQUEST['apply_auth'] == 1) {
M('sociaty_games','tab_')->where(['game_id'=>$gameId])->delete();
}
M('sociaty_games','tab_')->addAll($dataList);
if(!empty($_REQUEST['promote_data'])) {
$promote_data = json_decode($_REQUEST['promote_data'],TRUE);
$game_appid = $_REQUEST['game_appid'];
$gameId = M('game','tab_')->where(['game_appid' => $game_appid])->getField('id');
$gameInfo = M('game','tab_')->field('game_name,game_status')->where(['id'=>$gameId])->select();
$dataList = array();
foreach($promote_data as $key => $promoteInfo) {
$isSociaty = M('sociaty_games','tab_')->where(['promote_id'=>intval($promoteInfo['value']),'game_id'=>intval($gameId)])->getField('id');
if(!empty($isSociaty)) {
// $this->error("选择会长中有已存在会长");
}else {
$dataList[] = ['promote_id' => intval($promoteInfo['value']),'game_id' => intval($gameId),'status'=>$gameInfo[0]['game_status'],'create_time'=>time()];
}
}
M('sociaty_games','tab_')->addAll($dataList);
}
// $_REQUEST['apply_auth'] == 1 ? $this->success('开放全部会长权限成功') : $this->success('设置会长权限成功');
}
if ($_POST['game_score'] <0 || $_POST['game_score'] > 5) {
$this->error('游戏评分只能为0-5之间的数字');
@ -415,7 +441,30 @@ class GameController extends ThinkController
$data['icon_data'] = explode(',', $data['icon']);
}
$apply_auth = M('game','tab_')->where(['id'=>$id])->getField('apply_auth');
$this->assign('apply_auth',$apply_auth);
$sociatyGames = M('sociaty_games','tab_')->where(['game_id'=>$id])->select();
$sociatyGamesData = [];
if(!empty($sociatyGames)) {
foreach($sociatyGames as $key => $value) {
$sociatyGamesData[$key]['id'] = $value['id'];
if($value['promote_id'] == -1) {
$sociatyGamesData[$key]['promoteAccount'] = "官方渠道";
}else {
$promoteAccount = M('promote','tab_')->where(['id'=>$value['promote_id']])->getField('account');
$sociatyGamesData[$key]['promoteAccount'] = $promoteAccount;
}
$sociatyGamesData[$key]['create_time'] = date('Y-m-d H:i:s',$value['create_time']);
$applyStatus = M('apply','tab_')->field('id')->where(['game_id'=>$value['game_id'],'status'=>1])->select();
if(empty($applyStatus)) {
$sociatyGamesData[$key]['isPromote'] = "否";
}else {
$sociatyGamesData[$key]['isPromote'] = "是";
}
}
}
$this->assign('sociatygames',$sociatyGamesData);
$data['introduction'] = str_replace("~~", "\r\n", $data['introduction']);
$this->assign('data', $data);
$this->assign('game_id', $id);
@ -911,6 +960,7 @@ class GameController extends ThinkController
public function uploadExcel1() {
Vendor("PHPExcel.PHPExcel");
$gid = $_REQUEST['game_id'];
if(@is_uploaded_file($_FILES['file']['tmp_name'])){
$upfile = $_FILES["file"];
$name = $upfile["name"];
@ -921,10 +971,11 @@ class GameController extends ThinkController
move_uploaded_file($tmp_name,$savePath.$name);
$file_name = $savePath.$name;
$error=$upfile["error"];//上传后系统返回的值
// print($file_name);
$extension = strtolower( pathinfo($file_name, PATHINFO_EXTENSION) );
if($extension == 'xlsx') {
$objReader = \PHPExcel_IOFactory::createReader('excel2007');
}elseif($extension == 'csv') {
$objReader = \PHPExcel_IOFactory::createReader('csv');
}else {
$objReader = \PHPExcel_IOFactory::createReader('Excel5');//创建读取实例
}
@ -933,24 +984,38 @@ class GameController extends ThinkController
$highestRow = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
$dataList = [];
$outPromote = []; //录入出错的会长
$outGame = []; //录入出错的游戏
$keyPro = 0;
$keyGame = 0;
$keyData = 0;
for($i=2;$i<=$highestRow;$i++)
{
$promote_id = $objPHPExcel->getActiveSheet()->getCell("A".$i)->getValue();
$promoteInfo = M('promote','tab_')->field('account')->where(['id' => $promote_id ])->find();
$promoteAccount = $objPHPExcel->getActiveSheet()->getCell("A".$i)->getValue();
$promoteInfo = M('promote','tab_')->field('id')->where(['account' => $promoteAccount ])->find();
if($promote_id == -1) {$promoteInfo['account'] = "官方渠道"; }
if(empty($promoteInfo)) {
break;
}
$game_id = $objPHPExcel->getActiveSheet()->getCell("B".$i)->getValue();
$gameInfo = M('game','tab_')->field('game_name,game_status')->where(['id'=>$game_id])->select();
if(empty($gameInfo)) {
break;
$outPromote[$keyPro]['promote_account'] = $promoteAccount;
$keyPro += 1;
}else {
$promote_id = $promoteInfo['id'];
}
$gameInfo = M('game','tab_')->field('game_name,game_status')->where(['id'=>$gid])->select();
$time = time();
$dataList[] = ['promote_id'=>$promote_id,'game_id'=>$game_id,'status'=>$gameInfo[0]['game_status'],'create_time'=>$time];
$isSociaty = M('sociaty_games','tab_')->where(['promote_id'=>$promote_id,'game_id'=>$gid])->getField('id');
if(empty($isSociaty) && !empty($gameInfo) && !empty($promoteInfo)) {
$dataList[$keyData] = ['promote_id'=>$promote_id,'game_id'=>$gid,'status'=>$gameInfo[0]['game_status'],'create_time'=>$time];
$successAccount[$keyData] = ['account'=>$promoteAccount];
$keyData += 1;
}
}
M('sociaty_games','tab_')->addAll($dataList);
$this->ajaxReturn(json_encode($dataList));
$backData['outPromote'] = $outPromote;
$backData['datalist'] = $successAccount;
M('sociaty_games','tab_')->addAll($dataList);
$gameData['apply_auth'] = 2;
M('game','tab_')->where(['id'=>$gid])->save($gameData);
$this->ajaxReturn(json_encode($backData,TRUE));
}
}
@ -970,16 +1035,12 @@ class GameController extends ThinkController
$game_id = $_REQUEST['game_id'];
$game_name = M('game','tab_')->where(['id'=>$game_id])->getField('game_name');
$data[] = [
'promoteid' => 99,
'game_id' => $game_id,
'game_name' => $game_name
'promoteid' => "官方渠道",
];
$field = array(
"promoteid"=>"会长ID",
"game_id"=>"游戏ID(无需修改,已默认当前游戏)",
"game_name"=>"游戏名称(无需修改,已默认当前游戏)"
"promoteid"=>"会长账号",
);
data2csv($data,"模板",$field);
data2csv($data,'【'.$game_name.'】'.'模板',$field);
}
}

@ -944,13 +944,47 @@
<!--推广配置-->
<div id="tab6" class="tab-pane tab6 ">
<table border="0" cellspacing="0" cellpadding="0">
<input type="button" id="addpromote" onclick="addPromote()" style="background: #3E96C9;color:white;border:none;outline: none;width:90px;height:30px;border-radius: 3px;" value="添加" />
<div class="data_list data_game_list" id="addpromoteindex" style="margin-top:20px;">
<div class="">
<table>
<thead>
<tr>
<th>会长账号</th>
<th>添加时间</th>
<th>是否已进行推广</th>
<th style="width:10%;min-width:150px;">操作</th>
</tr>
</thead>
<tbody>
<if condition="$apply_auth eq 2">
<empty name ="sociatygames">
<td colspan="14" class="text-center">aOh! 暂时还没有内容!</td>
<else />
<volist name="sociatygames" id="data">
<tr>
<td>{$data['promoteAccount']}</td>
<td>{$data['create_time']}</td>
<td>{$data['isPromote']}</td>
<td class="" style="color:red"><a href="javascript:void()" onclick="del({$data['id']})">移除</a></td>
</tr>
</volist>
</empty>
<else/>
<td colspan="14" class="text-center">该游戏未设置会长权限,现面对所有会长开放!</td>
</if>
</tbody>
</table>
</div>
</div>
<table border="0" cellspacing="0" cellpadding="0" id="promoteset" style="display:none">
<tbody >
<tr style="display:block;width:600px;" >
<td class="l">推广限制</td>
<td class="r" >
<input type="radio" class="inp_radio js-device js-devices{$key}" value="" id="all" name="" checked> 全部会长可申请
<input type="radio" class="inp_radio js-device js-devices{$key}" value="" id="part" name="" style="margin-left:20px"> 部分会长可申请
<input type="radio" class="inp_radio js-device js-devices{$key}" value="0" id="all" name="apply_auth" checked> 全部会长可申请
<input type="radio" class="inp_radio js-device js-devices{$key}" value="0" id="part" name="apply_auth" style="margin-left:20px"> 部分会长可申请
</td>
</tr>
<tr style="display:none;width:600px;" id="addtype">
@ -978,7 +1012,7 @@
<td class="l">导入模板</td>
<td class="r" >
<input type="file" name="upfile" id="file_excel" style="width:200px"/>
<input type="button" onclick="suba()" style="background: #3E96C9;color:white;border:none;outline: none;width:70px;height:30px;border-radius: 3px;" value="导入" />
<input type="button" onclick="suba({$game_id})" style="background: #3E96C9;color:white;border:none;outline: none;width:70px;height:30px;border-radius: 3px;" value="导入" />
</td>
</tr>
@ -1078,6 +1112,7 @@
<script type="text/javascript">
$("#part").click(function() {
var addtype = document.getElementById("addtype");
addtype.style.display = "block"
$("#part").attr('checked',true)
$("#all").attr('checked',false)
@ -1085,6 +1120,8 @@
moban.style.display = "block"
var daoru = document.getElementById("daoru");
daoru.style.display = "block"
document.getElementById('all').value = 1
document.getElementById('part').value = 2
})
$("#all").click(function() {
var addtype = document.getElementById("addtype");
@ -1099,6 +1136,8 @@
daoru.style.display = "none"
document.getElementById("transfer_promote").style.display = "none"
document.getElementById("data_list").style.display = "none"
document.getElementById('all').value = 1
document.getElementById('part').value = 2
})
$("#excel").click(function() {
var moban = document.getElementById("moban");
@ -1122,12 +1161,39 @@
document.getElementById('transfer_promote').style.display = "block"
document.getElementById("data_list").style.display = "none"
})
function suba() {
function addPromote() {
var addpromoteindex = document.getElementById("addpromoteindex");
var addpromote = document.getElementById("addpromote");
var promoteset = document.getElementById("promoteset");
addpromoteindex.style.display = "none"
addpromote.style.display = "none"
promoteset.style.display = "block"
document.getElementById('all').value = 1
document.getElementById('part').value = 2
}
function del(id) {
var msg = "确认删除该项?"
if(confirm(msg) == true) {
$.ajax({
url:"{:U('Game/delSociatyGames')}",
dataType:'json',
type:'POST',
data:{'id':id},
success:function(res) {
console.log(res.code)
if(res.code == 10001) {
window.location.reload();
}
}
})
}
}
function suba(game_id) {
var file_excel = $('#file_excel')[0].files[0]
var formData = new FormData();
formData.append("file",file_excel);
formData.append("game_id",game_id)
$.ajax({
url:"{:U('Game/uploadExcel1')}",
dataType:'json',
@ -1138,19 +1204,36 @@
contentType : false, // 不要设置Content-Type请求头
success:function(res) {
document.getElementById('data_list').style.display = "block"
res = JSON.parse(res)
if(res.length > 0) {
html = '<div class=""><table><thead><tr><th>会长ID</th><th>游戏ID</th></tr></thead><tbody>'
res.forEach(v=>{
html += '<tr><td>'+v['promote_id']+'</td><td>'+v['game_id']+'</td></tr>';
var datalist = res.datalist
var outPromote = res.outPromote
if(datalist.length > 0) {
html = '<div class="" style="width:500px"><table><thead><tr><th>录入成功会长账号</th></tr></thead><tbody>'
datalist.forEach(v=>{
html += '<tr><td>'+v['account']+'</td></tr>';
})
}else {
html = '<div class=""><table><thead><tr><th>会长ID</th><th>游戏ID</th></tr></thead><tbody>'
+'<td colspan="14" class="text-center">aOh! 未找到相关游戏,请检查游戏列表!</td>'
html = '<div class="" style="width:500px"><table><thead><tr><th>录入成功会长账号</th></tr></thead><tbody>'
+'<td colspan="14" class="text-center">aOh! 暂无账号录入!</td>'
}
html += '</tbody></table></div>'
if(outPromote.length > 0) {
html += '<div class="" style="width:500px"><table><thead><tr><th>录入失败会长账号</th></tr></thead><tbody>'
outPromote.forEach(p=>{
html += '<tr><td>'+p['promote_account']+'</td></tr>';
})
}else {
html += '<div class="" style="width:500px"><table><thead><tr><th>录入失败会长账号</th></tr></thead><tbody>'
+'<td colspan="14" class="text-center">aOh! 暂无录入失败会长账号!</td>'
}
html += '</tbody></table></div>'
$("#data_list").html(html);
}
})

Loading…
Cancel
Save