You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
4.4 KiB
PHTML

2 years ago
<?php
namespace Admin\Controller;
use User\Api\UserApi as UserApi;
/**
* 后台首页控制器
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
class MendController extends ThinkController {
public function lists($p=1){
$this->m_title = '推广补链';
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Mend/lists','status'=>1])->find());
switch ($_GET['type']) {
case '':
case 1:
$this->mendList();
break;
default:
$this->recordList();
break;
}
}
public function mendList(){
if(isset($_REQUEST['account'])){
if ($_REQUEST['account']=='全部') {
unset($_REQUEST['account']);
}
$map['account']=array('like','%'.$_REQUEST['account'].'%');
unset($_REQUEST['account']);
}
$map['puid']=0;
$map['length(account)'] = array('gt', 0);
$map['register_time'] = array('gt', 0);
$p = I('p');
$map['register_type'] = array('in','(0,1,2,3,4,5,6,7)');
parent::lists("user",$p,$map);
}
public function recordList()
{
if(isset($_REQUEST['account'])){
if ($_REQUEST['account']=='全部') {
unset($_REQUEST['account']);
}
$map['user_account']=array('like','%'.$_REQUEST['account'].'%');
unset($_REQUEST['account']);
}
$p = I('p');
$this->assign('show_status',1);
parent::lists("Mend",$p,$map);
}
public function edit($id = null)
{
if (IS_POST) {
if ($_POST['prmoote_id_to'] == -1){
$_POST['prmoote_id_to'] = 0;
}
if ($_POST['prmoote_id_to'] === ''){
$this->error('请选择需要变更的渠道');
}
if ($_POST['promote_id'] == $_POST['prmoote_id_to']) {
$this->error('没有变更数据');
}
$create = $_REQUEST;
$map['id'] = $create['user_id'];
$map_['user_id'] = $create['user_id'];
$data['promote_id'] = $create['prmoote_id_to'];
$data['promote_account'] = get_promote_name($create['prmoote_id_to']);
// 加入补链时间
$data['rebind_time'] = $create['rebind_time'];
$user_data = $data;
$promote = M('promote', 'tab_')->where(array("id"=>I('prmoote_id_to')))->find();
if ($promote['parent_id'] != "0") {
$ppromote = M('promote', 'tab_')->where(array("id"=>$promote['parent_id']))->find();
$user_data['parent_id']=$ppromote['id'];
}else{
$user_data['parent_id'] = 0;
}
$user_data['parent_name']=get_promote_name($user_data['parent_id']);
$user = M('user', 'tab_')->where($map)->save($user_data);
$user_ = M('UserPlay', 'tab_')->where($map_)->save($data);
$puser_ = M('UserPlayInfo', 'tab_')->where($map_)->save($data);
$spend = M('Spend', 'tab_')->where($map_)->where(array('is_check'=>array('in','1,2')))->save($data);// spend只改未对账的数据
$depost = M('Deposit', 'tab_')->where($map_)->save($data);
$Bind_spend = M('Bind_spend', 'tab_')->where($map_)->save($data);
$create['user_account'] = get_user_account($create['user_id']);
$create['promote_account'] = get_promote_name($create['promote_id']);
$create['promote_id_to'] = $create['prmoote_id_to'];
$create['promote_account_to'] = get_promote_name($create['prmoote_id_to']);
$create['create_time'] = time();
$create['op_id'] = UID;
$create['op_account'] = session('user_auth.username');
$create['bind_type'] = $create['bind_type'];
$mend = M('mend', 'tab_')->add($create);
if ($mend) {
$this->success('补链成功', U('lists'), 2);
}
} else {
$user = A('User', 'Event');
$user_data = $user->user_entity($id);
$user_data || $this->error("用户数据异常");
// var_dump($user_data);die;
$this->assign("data", $user_data);
$this->meta_title = '编辑推广补链';
$this->m_title = '推广补链';
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Mend/lists','status'=>1])->find());
$this->display();
}
}
}