优化推广员选择

master
chenzhi 5 years ago
parent 3b9c49efa7
commit dfff8b6240

@ -1,5 +1,6 @@
<?php
namespace Admin\Controller;
use mysql_xdevapi\Exception;
use User\Api\PromoteApi;
use User\Api\UserApi;
@ -10,11 +11,12 @@ use Base\Service\PromoteService;
* 后台首页控制器
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
class PromoteController extends ThinkController {
class PromoteController extends ThinkController
{
const model_name = 'Promote';
public function lists($p=1){
public function lists($p=1)
{
switch ($_GET['type']) {
case '':
case 1:
@ -26,22 +28,27 @@ class PromoteController extends ThinkController {
}
}
private function promoteList($p){
private function promoteList($p)
{
// if (isset($_REQUEST['promote_id'])) {
// $promoteid = $_REQUEST['promote_id'];
// unset($_REQUEST['promote_id']);
// if (isset($_REQUEST['parent_id'])) {
// $parent_id = $_REQUEST['parent_id'];
// unset($_REQUEST['parent_id']);
// if ($promoteid == $parent_id) {
// $map['id'] = $promoteid;
// }
// } else {
// $map['id'] = $promoteid;
// }
// } else {
$promoteid = false;
if (isset($_REQUEST['promote_id'])) {
$promoteid = $_REQUEST['promote_id'];
unset($_REQUEST['promote_id']);
if(isset($_REQUEST['parent_id'])) {
$parent_id = $_REQUEST['parent_id'];
unset($_REQUEST['parent_id']);
if($promoteid == $parent_id) {
$map['id'] = $promoteid;
}
} else {
$map['id'] = $promoteid;
$map['id'] = $_REQUEST['promote_id'];
}
} else {
if (isset($_REQUEST['parent_id'])) {
if ($_REQUEST['parent_id']=='全部') {
unset($_REQUEST['parent_id']);
@ -52,10 +59,22 @@ unset($_REQUEST['parent_id']);
} else {
$zid=$_REQUEST['parent_id'];
}
//判断自己是否在里面
$zidarr = explode(",",$zid);
if ($promoteid > 0 ) {
if (in_array($promoteid,$zidarr)) {
# code...
$map['id'] = $promoteid;
}else{
$map['id'] = 0;
}
}else{
$map['id']=array('in',$zid);
unset($_REQUEST['parent_id']);
}
//
unset($_REQUEST['parent_id']);
}
if (isset($_REQUEST['admin_id'])) {
if ($_REQUEST['admin_id']=="全部") {
unset($_REQUEST['admin']);
@ -76,7 +95,11 @@ unset($_REQUEST['parent_id']);
}
$this->m_title = '推广员列表';
$this->assign('commonset', M('Kuaijieicon')->where(['url'=>'Promote/lists/type/1','status'=>1])->find());
if(isset($_REQUEST['row'])) {$row = $_REQUEST['row'];}else{$row = 10;}
if (isset($_REQUEST['row'])) {
$row = $_REQUEST['row'];
} else {
$row = 10;
}
if (I('oa_associated', -1) != -1) {
$map['oa_associated'] = I('oa_associated');
@ -94,7 +117,6 @@ unset($_REQUEST['parent_id']);
if ($re_data['code'] == 1) {
$oa = $re_data['data'];
$oa_data = array_merge($oa_data, $oa);
} else {
break;
}
@ -110,20 +132,19 @@ unset($_REQUEST['parent_id']);
M('promote', 'tab_')->where(['id' => $v['id']])->setField(['oa_associated' => $oa_val]);
}
}
}
// dump($map);die();
$list_data = D(self::model_name)->where($map)->order('id DESC')->page($p, $row)->select();
$oa_data = [];
if (I('oa_associated', -1) == -1) {
foreach($list_data as $k => $v)
{
foreach ($list_data as $k => $v) {
// $list_data[$k]['account'] = trim($v['account']);
// if($v['oa_associated'] != 1) {
$oa_data[] = trim($v['account']);
// }
}
if(!empty($oa_data))
{
if (!empty($oa_data)) {
$arr['time'] = time();
$arr['account'] = implode(",", $oa_data);
ksort($arr);
@ -132,26 +153,26 @@ unset($_REQUEST['parent_id']);
$arr['sign'] = $sign;
$re_data = curl_post('http://test.oa.76ba.com/api/wanmeng/verifyBind', $arr);
$re_data = json_decode($re_data, true)['data'];
foreach($list_data as $k => $v)
{
foreach ($list_data as $k => $v) {
$oa_val = $re_data[trim($v['account'])];
if ($v['oa_associated'] != $oa_val) {
$list_data[$k]['oa_associated'] = $oa_val;
M('promote', 'tab_')->where(['id' => $v['id']])->setField(['oa_associated' => $oa_val]);
}
}
}
}
$count = D(self::model_name)->where($map)->count();
$page = set_pagination($count, $row);
if($page) {$this->assign('_page', $page);}
if ($page) {
$this->assign('_page', $page);
}
$this->assign('list_data', $list_data);
$this->display();
}
private function siteApplyList($p){
private function siteApplyList($p)
{
if (isset($_REQUEST['promote_id'])) {
$map['promote_id']=$_REQUEST['promote_id'];
unset($_REQUEST['promote_id']);
@ -173,9 +194,12 @@ unset($_REQUEST['parent_id']);
parent::lists('SiteApply', $p, $map);
}
public function add($account=null,$password=null,$second_pwd=null,$real_name=null,$email=null,$mobile_phone=null,$bank_name=null,$bank_card=null,$admin=null,$status=null,$ba_id = null){
public function add($account=null, $password=null, $second_pwd=null, $real_name=null, $email=null, $mobile_phone=null, $bank_name=null, $bank_card=null, $admin=null, $status=null, $ba_id = null)
{
if (IS_POST) {
if(C('PROMOTE_AUTO_AUDIT') == 1){$status = 1;}
if (C('PROMOTE_AUTO_AUDIT') == 1) {
$status = 1;
}
$data = array('account'=>$account,'password'=>$password,'second_pwd'=>$second_pwd,'real_name'=>$real_name,'email'=>$email,'mobile_phone'=>$mobile_phone,'bank_name'=>$bank_name,'bank_card'=>$bank_card,'admin_id'=>$admin,'status'=>$status,'ba_id'=>$ba_id);
if (preg_match('/^[a-zA-Z0-9]{6,15}$/', $account)==false) {
@ -190,12 +214,10 @@ unset($_REQUEST['parent_id']);
$ba->add_child($_REQUEST['ba_id'],$res);
} */
$this->success("添加成功", U('lists'));
}
else{
} else {
$this->error($res);
}
}
else{
} else {
$this->meta_title ='新增渠道信息';
$this->m_title = '推广员列表';
$this->assign('commonset', M('Kuaijieicon')->where(['url'=>'Promote/lists/type/1','status'=>1])->find());
@ -203,19 +225,21 @@ unset($_REQUEST['parent_id']);
}
}
public function del($model = null, $ids=null){
public function del($model = null, $ids=null)
{
$model = M('Model')->getByName(self::model_name);
/*通过Model名称获取Model完整信息*/
parent::del($model["id"], $ids);
}
//代充删除
public function agent_del($model = null, $ids=null){
public function agent_del($model = null, $ids=null)
{
$model = M('Model')->getByName('Agent');
/*通过Model名称获取Model完整信息*/
parent::del($model["id"], $ids);
}
public function edit($id=0){
public function edit($id=0)
{
$id || $this->error('请选择要查看的用户!');
$model = M('Model')->getByName(self::model_name); /*通过Model名称获取Model完整信息*/
$data = array();
@ -248,8 +272,12 @@ unset($_REQUEST['parent_id']);
$use = new UserApi();
$data['password']=think_ucenter_md5($pwd, UC_AUTH_KEY);
$data['second_pwd']=think_ucenter_md5($second_pwd, UC_AUTH_KEY);
if(empty($pwd)){unset($data['password']);}
if(empty($second_pwd)){unset($data['second_pwd']);}
if (empty($pwd)) {
unset($data['password']);
}
if (empty($second_pwd)) {
unset($data['second_pwd']);
}
$ba_id = D('Promote')->field("ba_id")->find($id);
if ($ba_id['ba_id'] != $_REQUEST['ba_id'] && $_REQUEST['ba_id']!='') {
@ -260,12 +288,10 @@ unset($_REQUEST['parent_id']);
$res=M("promote", "tab_")->where(array("id"=>$_POST['id']))->save($data);
if ($res !== false) {
$this->success("修改成功", U('lists'));
}
else{
} else {
$this->error("修改失败");
}
}
else{
} else {
$model = D('Promote');
$data = $model->find($id);
$data['bank_area']=explode(',', $data['bank_area']);
@ -312,8 +338,8 @@ unset($_REQUEST['parent_id']);
}
}
//设置状态
public function set_status($model='Promote'){
public function set_status($model='Promote')
{
if (empty($_REQUEST['ids'])) {
$this->error('请选择要操作的数据');
}
@ -336,7 +362,6 @@ unset($_REQUEST['parent_id']);
} else {
$this->success('操作成功');
}
} else {
$this->success('操作失败');
}
@ -345,7 +370,8 @@ unset($_REQUEST['parent_id']);
/**
*资质审核
*/
public function idcar_status($model='Promote') {
public function idcar_status($model='Promote')
{
if (empty($_REQUEST['ids'])) {
$this->error('请选择要操作的数据');
}
@ -368,7 +394,6 @@ unset($_REQUEST['parent_id']);
} else {
$this->success('操作成功');
}
} else {
$set=M('promote', 'tab_')->where($map)->setField('ver_status', 2);
$this->success('操作失败');
@ -393,7 +418,8 @@ unset($_REQUEST['parent_id']);
//设置对账状态yyh
public function set_check_status($model='Promote'){
public function set_check_status($model='Promote')
{
if (isset($_REQUEST['model'])) {
$model=$_REQUEST['model'];
unset($_REQUEST['model']);
@ -403,7 +429,8 @@ unset($_REQUEST['parent_id']);
/**
*渠道注册列表
*/
public function ch_reg_list(){
public function ch_reg_list()
{
if (isset($_REQUEST['game_name'])) {
if ($_REQUEST['game_name']=='全部') {
unset($_REQUEST['game_name']);
@ -427,21 +454,15 @@ unset($_REQUEST['parent_id']);
if (isset($_REQUEST['parent_id'])) {
$parent_id = get_promote_id($_REQUEST['parent_id']);
if ($promoteid == $parent_id) {
$map['tab_user.promote_id'] = $promoteid;
} else {
$parent_id = get_promote_id($_REQUEST['parent_id']);
}
} else {
$map['tab_user.promote_id'] = $promoteid;
}
}
} else {
if (isset($_REQUEST['parent_id'])) {
$parent_id = get_promote_id($_REQUEST['parent_id']);
$pro = M('promote', 'tab_')->field('id,account')->where("chain like '%/{$parent_id}/%'")->select();
@ -453,11 +474,9 @@ unset($_REQUEST['parent_id']);
$map['tab_user.promote_id'] = array('eq',-1);
}
}
}
if (isset($_REQUEST['ba_id'])) {
$map['ba_id'] = $_REQUEST['ba_id'];
}
if (isset($_REQUEST['is_check'])&&$_REQUEST['is_check']!="请选择") {
$map['is_check']=$_REQUEST['is_check'];
@ -469,7 +488,8 @@ unset($_REQUEST['parent_id']);
}
if (isset($_REQUEST['time-start'])&&isset($_REQUEST['time-end'])) {
$map['register_time']=array('BETWEEN',array(strtotime($_REQUEST['time-start']),strtotime($_REQUEST['time-end'])+24*60*60-1));
unset($_REQUEST['time-start']);unset($_REQUEST['time_end']);
unset($_REQUEST['time-start']);
unset($_REQUEST['time_end']);
} elseif (isset($_REQUEST['time-start'])) {
$map['register_time'] = ['GT',strtotime(I('time-start'))];
unset($_REQUEST['time-start']);
@ -479,7 +499,8 @@ unset($_REQUEST['parent_id']);
}
if (isset($_REQUEST['start'])&&isset($_REQUEST['end'])) {
$map['register_time']=array('BETWEEN',array(strtotime($_REQUEST['start']),strtotime($_REQUEST['end'])+24*60*60-1));
unset($_REQUEST['start']);unset($_REQUEST['end']);
unset($_REQUEST['start']);
unset($_REQUEST['end']);
} elseif (isset($_REQUEST['start'])) {
$map['register_time'] = ['GT',strtotime(I('start'))];
unset($_REQUEST['start']);
@ -527,13 +548,13 @@ unset($_REQUEST['parent_id']);
$user->user_join_v1($model, $_GET['p']);
}
/**
*渠道充值
*/
public function spend_list(){
public function spend_list()
{
if (isset($_REQUEST['game_name'])) {
if ($_REQUEST['game_name']=='全部') {
unset($_REQUEST['game_name']);
@ -568,7 +589,8 @@ unset($_REQUEST['parent_id']);
if (isset($_REQUEST['timeStart'])&&isset($_REQUEST['timeEnd'])) {
$map['pay_time']=array('BETWEEN',array(strtotime($_REQUEST['timeStart']),strtotime($_REQUEST['timeEnd'])+24*60*60-1));
unset($_REQUEST['timeStart']);unset($_REQUEST['timeEnd']);
unset($_REQUEST['timeStart']);
unset($_REQUEST['timeEnd']);
} elseif (isset($_REQUEST['timeStart'])) {
$map['pay_time'] = ['GT',strtotime(I('timeStart'))];
unset($_REQUEST['timeStart']);
@ -578,7 +600,8 @@ unset($_REQUEST['parent_id']);
}
if (isset($_REQUEST['start'])&&isset($_REQUEST['end'])) {
$map['pay_time']=array('BETWEEN',array(strtotime($_REQUEST['start']),strtotime($_REQUEST['end'])+24*60*60-1));
unset($_REQUEST['start']);unset($_REQUEST['end']);
unset($_REQUEST['start']);
unset($_REQUEST['end']);
} elseif (isset($_REQUEST['start'])) {
$map['pay_time'] = ['GT',strtotime(I('start'))];
unset($_REQUEST['start']);
@ -597,27 +620,18 @@ unset($_REQUEST['parent_id']);
$map['promote_id']=get_promote_id($_REQUEST['promote_name']);
unset($_REQUEST['promote_name']);
if (!empty(I('parent_id')) && $map['promote_id']) {
if (I('parent_id') == $map['promote_id']) {
} else {
$pro = M('promote', 'tab_')->field('id')->where("chain like '%/{$_REQUEST['parent_id']}/%' or id={$_REQUEST['parent_id']}")->select();
if (!$pro) {
$map['promote_id'] = array('eq',999999999);
}
}
} else {
}
}
} else {
if (!empty(I('parent_id'))) {
$pro = M('promote', 'tab_')->field('id')->where("chain like '%/{$_REQUEST['parent_id']}/%'")->select();
$pro_ids = array_column($pro, 'id');
@ -630,7 +644,6 @@ unset($_REQUEST['parent_id']);
} else {
$map['promote_id']=array("gt",0);
}
}
@ -669,7 +682,8 @@ unset($_REQUEST['parent_id']);
/**
*代充记录
*/
public function agent_list(){
public function agent_list()
{
$map['promote_id'] = array("neq",0);
if (isset($_REQUEST['user_account'])) {
$map['user_account']=array('like','%'.$_REQUEST['user_account'].'%');
@ -693,17 +707,21 @@ unset($_REQUEST['parent_id']);
}
if (isset($_REQUEST['time-start'])&&isset($_REQUEST['time-end'])) {
$map['create_time']=array('BETWEEN',array(strtotime($_REQUEST['time-start']),strtotime($_REQUEST['time-end'])+24*60*60-1));
unset($_REQUEST['time-start']);unset($_REQUEST['time_end']);
unset($_REQUEST['time-start']);
unset($_REQUEST['time_end']);
} elseif (isset($_REQUEST['time-start'])) {
$map['create_time']=array('BETWEEN',array(strtotime($_REQUEST['time-start']),time()));
unset($_REQUEST['time-start']);unset($_REQUEST['time_end']);
unset($_REQUEST['time-start']);
unset($_REQUEST['time_end']);
} elseif (isset($_REQUEST['time-end'])) {
$map['create_time']=array('BETWEEN',array(0,strtotime($_REQUEST['time-end'])+24*60*60-1));
unset($_REQUEST['time-start']);unset($_REQUEST['time_end']);
unset($_REQUEST['time-start']);
unset($_REQUEST['time_end']);
}
if (isset($_REQUEST['start'])&&isset($_REQUEST['end'])) {
$map['create_time']=array('BETWEEN',array(strtotime($_REQUEST['start']),strtotime($_REQUEST['end'])+24*60*60-1));
unset($_REQUEST['start']);unset($_REQUEST['end']);
unset($_REQUEST['start']);
unset($_REQUEST['end']);
}
if (isset($_REQUEST['game_name'])) {
if ($_REQUEST['game_name']=='全部') {
@ -733,7 +751,8 @@ unset($_REQUEST['parent_id']);
/**
*代充额度
*/
public function pay_limit(){
public function pay_limit()
{
if (isset($_REQUEST['account'])) {
if ($_REQUEST['account']=='全部') {
unset($_REQUEST['account']);
@ -858,8 +877,8 @@ unset($_REQUEST['parent_id']);
/**
*删除混服申请数据
*/
public function delSiteApply(){
public function delSiteApply()
{
$ids = array_unique((array)I('post.ids', 0));
if (empty($ids)) {
$this->error('请选择要操作的数据!');
@ -876,7 +895,8 @@ unset($_REQUEST['parent_id']);
/**
*审核混服申请数据
*/
public function checkSiteApply($ids=null){
public function checkSiteApply($ids=null)
{
$ids = array_unique((array)I('post.ids', 0));
if (empty($ids)) {
$this->error('请选择要操作的数据!');
@ -902,7 +922,8 @@ unset($_REQUEST['parent_id']);
}
}
public function del_promote(){
public function del_promote()
{
if (IS_AJAX) {
M()->startTrans();
$result = M('promote', 'tab_')->where("chain like '%/{$_POST['id']}/%' or id={$_POST['id']} ")->delete();
@ -917,7 +938,8 @@ unset($_REQUEST['parent_id']);
}
//获取推广员可推广游戏
public function getPromoteGame(){
public function getPromoteGame()
{
if (IS_AJAX) {
//获取所有游戏
$game_list = M('game', 'tab_')->field('id,game_name,short')->where(['game_status'=>1,'down_port'=>1])->select();
@ -932,14 +954,15 @@ unset($_REQUEST['parent_id']);
$data['msg'] = '请求成功';
$data['code'] = 1;
$this->ajaxReturn($data);exit;
$this->ajaxReturn($data);
exit;
}
}
//更新推广员可推广游戏
public function savePromoteGame(){
public function savePromoteGame()
{
if (IS_AJAX) {
$id = I('promote_id', 0, 'intval');
if (empty($id)) {
@ -960,7 +983,8 @@ unset($_REQUEST['parent_id']);
}
}
public function shortCutMenu($p = 1) {
public function shortCutMenu($p = 1)
{
$page = intval($p);
$page = $page ? $page : 1; //默认显示第一页数据
$row=10;
@ -973,15 +997,16 @@ unset($_REQUEST['parent_id']);
$count = M("quick_menu", "tab_")->count();
$page = set_pagination($count, $row);
if($page) {$this->assign('_page', $page);}
if ($page) {
$this->assign('_page', $page);
}
$this->assign('list', $list);
$this->display();
}
public function shortCutMenuEdit() {
public function shortCutMenuEdit()
{
$id = I("id");
$where['id'] = $id;
@ -993,8 +1018,8 @@ unset($_REQUEST['parent_id']);
$this->display();
}
public function shortCutMenuSave() {
public function shortCutMenuSave()
{
$where['id'] = I("id");
$save['icon'] = I("icon");
$save['name'] = I("name");
@ -1008,7 +1033,5 @@ unset($_REQUEST['parent_id']);
M('quick_menu', 'tab_')->commit(); //提交事物
$this->success('保存成功', U("promote/shortCutMenu"));
}
}

@ -197,7 +197,7 @@
<tbody>
<if condition = "empty($list_data)">
<tr>
<td colspan="14" class="text-center">aOh! 暂时还没有内容!</td>
<td colspan="16" class="text-center">aOh! 暂时还没有内容!</td>
</tr>
</if>
<notemtpy name = "list_data">

@ -1995,18 +1995,34 @@ function get_parent_promote_($prmote_id=0,$isShwo=true)
//获取当前子渠道
function get_zi_promote_id($id){
$map['parent_id']=$id;
$map['grand_id'] = $id;
$map['_logic'] = 'or';
$pro=M("promote","tab_")->field('id')->where($map)->select();
if(null==$pro){
return 0;
}else{
for ($i=0; $i <count($pro); $i++) {
$sd[]=implode(",", $pro[$i]);
}
return implode(",", $sd);
// $map['parent_id']=$id;
// $map['grand_id'] = $id;
// $map['_logic'] = 'or';
// $pro=M("promote","tab_")->field('id')->where($map)->select();
// if(null==$pro){
// return 0;
// }else{
// for ($i=0; $i <count($pro); $i++) {
// $sd[]=implode(",", $pro[$i]);
// }
// return implode(",", $sd);
// }
$promote = M("promote","tab_");
//获取自己的等级
$self = $promote->field("chain,level")->where("id = '{$id}'")->find();
if ($self['level'] == 1) {
$self['chain'] = "/{$id}/";
}
$map['status'] = 1;
$map["chain"] = array("LIKE","%{$self['chain']}%");
$map["level"] = array("GT",$self['level']);
$data = $promote->field("id")->where($map)->select();
if(empty($data)){return array();}
$data = implode(",",array_column($data,"id"));
return $data;
}
/**

Loading…
Cancel
Save