init: 从宝塔同步到 Gitea
This commit is contained in:
Executable
+757
@@ -0,0 +1,757 @@
|
||||
<?php
|
||||
namespace app\agent\controller;
|
||||
use pay\Usdt;
|
||||
use \think\Controller;
|
||||
use think\Lang;
|
||||
use \think\Session;
|
||||
use \think\Request;
|
||||
use \think\Db;
|
||||
class Agent Extends Common{
|
||||
public function index(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
// 用于分页和搜索查询的数据
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get',$get);
|
||||
$this->assign('query',$query);
|
||||
// 搜索代理
|
||||
$username = trim(Request::instance()->get('username'));
|
||||
$agent_id = trim(Request::instance()->get('agent_id'));
|
||||
$is_under = trim(Request::instance()->get('is_under'));
|
||||
if($agent_id > 0){
|
||||
// 获取查询代理信息
|
||||
$agent = Session::get('user_info');
|
||||
$user_info = Db::connect('DB2')->name('user')->where('id',$agent_id)->find();
|
||||
$user_info['account_type'] = $agent['account_type'];
|
||||
}else{
|
||||
// 登录用户信息
|
||||
$user_info = Session::get('user_info');
|
||||
}
|
||||
if(!$is_under){
|
||||
$is_under = 2;
|
||||
$get['is_under'] = 2;
|
||||
$this->assign('get',$get);
|
||||
}
|
||||
|
||||
// 总代类型
|
||||
$topAgentId = explode(',',$user_info['agent_parent_id_path'])[0];
|
||||
$topAgent = Db::name('user')->where('id',$topAgentId)->find();
|
||||
$user_info['top_agent_type'] = $topAgent['agent_type'];
|
||||
$user_info['top_agent_pay_channel'] = $topAgent['pay_channel'];
|
||||
|
||||
// 拼装查询条件
|
||||
$where = array();
|
||||
$where['is_delete'] = 0;
|
||||
$where['agent'] = 1;
|
||||
if($is_under == 1){
|
||||
if($user_info['agent_parent_id'] > 0){
|
||||
$where['agent_parent_id_path'] = array('like','%,'.$user_info['id'].',%');
|
||||
}else{
|
||||
$where['agent_parent_id_path'] = array('like',$user_info['id'].',%');
|
||||
}
|
||||
}else{
|
||||
$where['agent_parent_id'] = $user_info['id'];
|
||||
}
|
||||
if($username){
|
||||
$where['username'] = $username;
|
||||
$agent_list = Db::connect('DB2')->name('user')->where($where)->order('id asc')->paginate(20,false,array('query'=>$get));
|
||||
}else{
|
||||
$agent_list = Db::connect('DB2')->name('user')->where($where)->whereOr('id',$user_info['id'])->order('id asc')->paginate(20,false,array('query'=>$get));
|
||||
}
|
||||
foreach($agent_list as $k => $v){
|
||||
//充值分级
|
||||
$agent_parent_id_path_arr = explode(',',$v['agent_parent_id_path']);
|
||||
$agent_id_intersect = array_intersect(LEVEL_AGENT_ID,$agent_parent_id_path_arr);
|
||||
if($v['agent'] == 0 && !empty($agent_id_intersect)){
|
||||
$v['onlineRecharge'] = Db::name('recharge')->where(array('type' => 4, 'mode' => 1, 'user_id' => $v['id']))->sum('amount');
|
||||
$v['onlineRechargeTitle'] = recharge_title(intval($v['onlineRecharge']));
|
||||
}else{
|
||||
$v['onlineRecharge'] = '-';
|
||||
$v['onlineRechargeTitle'] = '-';
|
||||
}
|
||||
// 检测是否有下级代理和会员
|
||||
$v['childAgent'] = false;
|
||||
$v['childMember'] = false;
|
||||
$childAgent = Db::connect('DB2')->name('user')->where(['is_delete'=>0,'agent_parent_id'=>$v['id'],'agent'=>1])->find();
|
||||
$childMember = Db::connect('DB2')->name('user')->where(['is_delete'=>0,'agent_parent_id'=>$v['id'],'agent'=>0])->find();
|
||||
if($childAgent){
|
||||
$v['childAgent'] = true;
|
||||
}
|
||||
if($childMember){
|
||||
$v['childMember'] = true;
|
||||
}
|
||||
if($v['type_xima'] == 1){
|
||||
/*
|
||||
$v['ximalv'] = $lang['bilateral'].' '.$v['agent_ximalv'].' / '.$v['agent_ximalv_dt'].' / '.$v['agent_ximalv_nn'].' / '.$v['agent_ximalv_tc'];*/
|
||||
$v['ximalv'] = $lang['bilateral'].' '.$v['agent_ximalv'].' / '.$v['agent_ximalv_dt'].' / '.$v['agent_ximalv_nn'];
|
||||
}elseif($v['type_xima'] == 2){
|
||||
/*
|
||||
$v['ximalv'] = $lang['unilateral'].' '.$v['agent_ximalv'].' / '.$v['agent_ximalv_dt'].' / '.$v['agent_ximalv_nn'].' / '.$v['agent_ximalv_tc'];*/
|
||||
$v['ximalv'] = $lang['unilateral'].' '.$v['agent_ximalv'].' / '.$v['agent_ximalv_dt'].' / '.$v['agent_ximalv_nn'];
|
||||
}else{
|
||||
$v['ximalv'] = '0 / 0 / 0';
|
||||
}
|
||||
// 状态和时间
|
||||
if($v['status'] == 0) $v['statusMsg'] = $lang['ban'];
|
||||
if($v['status'] == 1) $v['statusMsg'] = $lang['enable'];
|
||||
$v['reg_time'] = date('Y-m-d H:i:s',$v['reg_time']);
|
||||
|
||||
// 钱包地址
|
||||
$v['wallet_address'] = Db::name('user_wallet')->where('user_id',$v['id'])->value('address');
|
||||
|
||||
// 余额
|
||||
$userWhere = [];
|
||||
$userWhere['is_delete'] = 0;
|
||||
$userWhere['status'] = 1;
|
||||
if($v['agent_parent_id'] > 0){
|
||||
$userWhere['agent_parent_id_path'] = array('LIKE','%,'.$v['id'].',%');
|
||||
}else{
|
||||
$userWhere['agent_parent_id_path'] = array('LIKE',$v['id'].',%');
|
||||
}
|
||||
$v['all_money'] = Db::name('user')->where($userWhere)->sum('money');
|
||||
$agent_list[$k] = $v;
|
||||
}
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('user_info',$user_info);
|
||||
$this->assign('agent_list',$agent_list);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 已删除代理页面
|
||||
public function delete(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
// 获取管理员信息
|
||||
$user_info = Session::get('user_info');
|
||||
if($user_info['account_type'] == 2 || $user_info['account_type'] == 3){
|
||||
return '非法请求';
|
||||
}
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::connect('DB2')->name('user')->where('id',$user_info['id'])->find();
|
||||
$user_info['account_type'] = $account_type;
|
||||
|
||||
// 用于分页和搜索查询的数据
|
||||
$get = Request::instance()->get();
|
||||
$get['searchUrl'] = '/agent/index';
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get',$get);
|
||||
$this->assign('query',$query);
|
||||
|
||||
// 搜索代理
|
||||
$username = trim(Request::instance()->get('username'));
|
||||
$where = array();
|
||||
$where['is_delete'] = 1;
|
||||
$where['agent'] = 1;
|
||||
$where['agent_parent_id'] = $user_info['id'];
|
||||
if($username){
|
||||
$where['username'] = $username;
|
||||
$agent_list = Db::connect('DB2')->name('user')->where($where)->order('agent_level asc')->paginate(15,false,array('query'=>$get));
|
||||
}else{
|
||||
$agent_list = Db::connect('DB2')->name('user')->where($where)->order('agent_level asc')->paginate(15,false,array('query'=>$get));
|
||||
}
|
||||
|
||||
foreach($agent_list as $k => $v){
|
||||
$v['reg_time'] = date('Y-m-d H:i:s',$v['reg_time']);
|
||||
$agent_list[$k] = $v;
|
||||
}
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('user_info',$user_info);
|
||||
$this->assign('agent_list',$agent_list);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 添加代理页面
|
||||
public function add(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
// 获取管理员信息
|
||||
$user_info = Session::get('user_info');
|
||||
if($user_info['account_type'] == 2 || $user_info['account_type'] == 3){
|
||||
return $lang['illegal_request'];
|
||||
}
|
||||
// 获取父代理信息
|
||||
$parent_id = Request::instance()->get('parent_id');
|
||||
$agentParent = Db::name('user')->where('id',$parent_id)->find();
|
||||
if(!$agentParent || $agentParent['agent'] == 0){
|
||||
echo $lang['parent_error'];
|
||||
die();
|
||||
}
|
||||
|
||||
if($parent_id == CREDIT_AGENT_ID){//是否需要字母前缀
|
||||
$newLetter = config('letters');//A-Z数组
|
||||
}else{
|
||||
$newLetter = $agentParent['letter']?[$agentParent['letter']]:[];
|
||||
}
|
||||
|
||||
// 总代性质
|
||||
$topAgentId = explode(',',$user_info['agent_parent_id_path'])[0];
|
||||
$topAgent = Db::name('user')->where('id',$topAgentId)->find();
|
||||
$user_info['agent_type'] = $topAgent['agent_type'];
|
||||
|
||||
$manager_list = [];
|
||||
if($agentParent['bet_type'] == 2){
|
||||
if($agentParent['agent_parent_id'] == 0){
|
||||
$manager_list = Db::name('manager')->where('parent_agent_id',$agentParent['id'])->where('status',1)->field(['id','nickname'])->select();
|
||||
}else{
|
||||
$whereManager = explode(',',$agentParent['agent_manager_id_list']);
|
||||
$manager_list = Db::name('manager')->whereIn('id',$whereManager)->where('status',1)->field(['id','nickname'])->select();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//渲染参数和模板
|
||||
$this->assign('newLetter',$newLetter);
|
||||
$this->assign('user_info',$user_info);
|
||||
$this->assign('agentParent',$agentParent);
|
||||
$this->assign('manager_list',$manager_list);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 处理添加代理
|
||||
public function do_add(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
if(Request::instance()->post()){
|
||||
// 获取管理员信息
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::name('user')->where('id',$user_info['id'])->find();
|
||||
$user_info['account_type'] = $account_type;
|
||||
|
||||
|
||||
// 接收参数
|
||||
$parent_id = intval(Request::instance()->post('parent_id'));
|
||||
$letter = trim(Request::instance()->post('letter'));
|
||||
$username = trim(Request::instance()->post('username'));
|
||||
$nickname = trim(Request::instance()->post('nickname'));
|
||||
$password = trim(Request::instance()->post('password'));
|
||||
$repassword = trim(Request::instance()->post('repassword'));
|
||||
$mobile = trim(Request::instance()->post('mobile'));
|
||||
//$bet_type = Request::instance()->post('bet_type');
|
||||
$bet_type = $user_info['bet_type'];
|
||||
$limit_low = round(Request::instance()->post('limit_low'),2);
|
||||
$limit_high = round(Request::instance()->post('limit_high'),2);
|
||||
$limit_low_tie = round(Request::instance()->post('limit_low_tie'),2);
|
||||
$limit_high_tie = round(Request::instance()->post('limit_high_tie'),2);
|
||||
$limit_low_pair = round(Request::instance()->post('limit_low_pair'),2);
|
||||
$limit_high_pair = round(Request::instance()->post('limit_high_pair'),2);
|
||||
$limit_low_nn = round(Request::instance()->post('limit_low_nn'),2);
|
||||
$limit_high_nn = round(Request::instance()->post('limit_high_nn'),2);
|
||||
$agent_ximalv = round(Request::instance()->post('agent_ximalv'),2);
|
||||
$agent_ximalv_dt = round(Request::instance()->post('agent_ximalv_dt'),2);
|
||||
$agent_ximalv_nn = round(Request::instance()->post('agent_ximalv_nn'),2);
|
||||
$agent_ximalv_tc = round(Request::instance()->post('agent_ximalv_tc'),2);
|
||||
$agent_cs = round(Request::instance()->post('agent_cs'));
|
||||
$rebate_rate = Request::instance()->post('rebate_rate');
|
||||
$manager_list = Request::instance()->post('manager_list');
|
||||
$remark = Request::instance()->post('remark');
|
||||
|
||||
// 验证数据
|
||||
if($parent_id <= 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['parent_error']]));
|
||||
}
|
||||
$agentParent = Db::name('user')->where('id',$parent_id)->find();
|
||||
if(!$agentParent || $agentParent['agent'] == 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['parent_error']]));
|
||||
}
|
||||
if($agentParent['bet_type'] == 2){
|
||||
if(!$manager_list){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['select_manager']]));
|
||||
}
|
||||
}
|
||||
if(!$username){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['empty_username']]));
|
||||
}
|
||||
$user = Db::name('user')->where('username',$username)->find();
|
||||
if($user){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['already_exist_username']]));
|
||||
}
|
||||
if($letter && !in_array($letter,config('letters'))){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['letter_identification_error']]));
|
||||
}
|
||||
if(!$nickname){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['empty_nickname']]));
|
||||
}
|
||||
if(!$password){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['empty_password']]));
|
||||
}
|
||||
if(strlen($password) < 6){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['new_pass_limit']]));
|
||||
}
|
||||
if($password != $repassword){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['pass_diff']]));
|
||||
}
|
||||
if($bet_type > 3 && $bet_type <= 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['bet_type_error']]));
|
||||
}
|
||||
if($limit_low < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_limit_0']]));
|
||||
}
|
||||
if($limit_high < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['max_limit_0']]));
|
||||
}
|
||||
if($limit_low > $limit_high && $limit_low > 0 && $limit_high > 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_limit_bigger_than_max_limit']]));
|
||||
}
|
||||
if($limit_low_tie < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_tie_limit_0']]));
|
||||
}
|
||||
if($limit_high_tie < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['max_tie_limit_0']]));
|
||||
}
|
||||
if($limit_low_tie > $limit_high_tie && $limit_low_tie > 0 && $limit_high_tie > 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_tie_limit_bigger_than_max_tie_limit']]));
|
||||
}
|
||||
if($limit_low_pair < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_pair_limit_0']]));
|
||||
}
|
||||
if($limit_high_pair < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['max_pair_limit_0']]));
|
||||
}
|
||||
if($limit_low_pair > $limit_high_pair && $limit_low_pair > 0 && $limit_high_pair > 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_pair_limit_bigger_than_max_tie_limit']]));
|
||||
}
|
||||
if($limit_low_nn < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_nn_limit_0']]));
|
||||
}
|
||||
if($limit_high_nn < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['max_nn_limit_0']]));
|
||||
}
|
||||
if($limit_low_nn > $limit_high_nn && $limit_low_nn > 0 && $limit_high_nn > 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_nn_limit_bigger_than_max']]));
|
||||
}
|
||||
if($limit_low < $agentParent['limit_low'] || $limit_low > $agentParent['limit_high'] || $limit_high < $agentParent['limit_low'] || $limit_high > $agentParent['limit_high']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['limit_cannot_bigger'].' '.$agentParent['limit_low'].'-'.$agentParent['limit_high']]));
|
||||
}
|
||||
if($limit_low_tie < $agentParent['limit_low_tie'] || $limit_low_tie > $agentParent['limit_high_tie'] || $limit_high_tie < $agentParent['limit_low_tie'] || $limit_high_tie > $agentParent['limit_high_tie']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['tie_limit_cannot_bigger'].' '.$agentParent['limit_low_tie'].'-'.$agentParent['limit_high_tie']]));
|
||||
}
|
||||
if($limit_low_pair < $agentParent['limit_low_pair'] || $limit_low_pair > $agentParent['limit_high_pair'] || $limit_high_pair < $agentParent['limit_low_pair'] || $limit_high_pair > $agentParent['limit_high_pair']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['pair_limit_cannot_bigger'].' '.$agentParent['limit_low_pair'].'-'.$agentParent['limit_high_pair']]));
|
||||
}
|
||||
if($limit_low_nn > 0 && $limit_high_nn > 0 && $agentParent['limit_low_nn'] > 0 && $agentParent['limit_high_nn'] > 0){
|
||||
if($limit_low_nn < $agentParent['limit_low_nn'] || $limit_low_nn > $agentParent['limit_high_nn'] || $limit_high_nn < $agentParent['limit_low_nn'] || $limit_high_nn > $agentParent['limit_high_nn']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['nn_limit_cannot_bigger'].' '.$agentParent['limit_low_nn'].'-'.$agentParent['limit_high_nn']]));
|
||||
}
|
||||
}
|
||||
if($agent_ximalv < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['baccarat_limit_0']]));
|
||||
}
|
||||
if($agent_ximalv > $agentParent['agent_ximalv']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['baccarat_cannot_bigger_agent'].' '.$agentParent['agent_ximalv'].'!']));
|
||||
}
|
||||
if($agent_ximalv_dt < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['dt_limit_0']]));
|
||||
}
|
||||
if($agent_ximalv_dt > $agentParent['agent_ximalv_dt']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['dt_cannot_bigger_agent'].' '.$agentParent['agent_ximalv_dt'].'!']));
|
||||
}
|
||||
if($agent_ximalv_nn < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['cow_limit_0']]));
|
||||
}
|
||||
if($agent_ximalv_nn > $agentParent['agent_ximalv_nn']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['cow_cannot_bigger_agent'].' '.$agentParent['agent_ximalv_nn'].'!']));
|
||||
}
|
||||
if($agent_ximalv_tc < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['tc_limit_0']]));
|
||||
}
|
||||
if($agent_ximalv_tc > $agentParent['agent_ximalv_tc']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['tc_cannot_bigger_agent'].' '.$agentParent['agent_ximalv_tc'].'!']));
|
||||
}
|
||||
if($agent_cs > $agentParent['agent_cs']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['proportion_cannot_bigger_agent'].' '.$agentParent['agent_cs'].'!']));
|
||||
}
|
||||
if($rebate_rate > $agentParent['rebate_rate']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['rebate_cannot_bigger_agent'].' '.$agentParent['rebate_rate'].'!']));
|
||||
}
|
||||
|
||||
// 拼装数据创建代理
|
||||
$user_data = array();
|
||||
$user_data['username'] = $username;
|
||||
$user_data['agent_manager_id_list'] = $manager_list;
|
||||
$user_data['letter'] = $letter;
|
||||
$user_data['nickname'] = $nickname;
|
||||
$user_data['password'] = think_ucenter_md5($password, UC_AUTH_KEY);
|
||||
$user_data['encrypt'] = getRandChar();
|
||||
$user_data['mobile'] = $mobile;
|
||||
$user_data['status'] = 1;
|
||||
$user_data['agent'] = 1;
|
||||
$user_data['type_xima'] = $agentParent['type_xima'];
|
||||
$user_data['share_xima'] = $agentParent['share_xima'];
|
||||
$user_data['agent_ximalv'] = $agent_ximalv;
|
||||
$user_data['agent_ximalv_dt'] = $agent_ximalv_dt;
|
||||
$user_data['agent_ximalv_nn'] = $agent_ximalv_nn;
|
||||
$user_data['agent_ximalv_tc'] = $agent_ximalv_tc;
|
||||
$user_data['agent_cs'] = $agent_cs;
|
||||
$user_data['rebate_rate'] = $rebate_rate;
|
||||
$user_data['agent_parent_id'] = $agentParent['id'];
|
||||
$user_data['agent_parent_username'] = $agentParent['username'];
|
||||
$user_data['agent_parent_nickname'] = $agentParent['nickname'];
|
||||
$user_data['limit_low'] = $limit_low;
|
||||
$user_data['limit_high'] = $limit_high;
|
||||
$user_data['limit_low_tie'] = $limit_low_tie;
|
||||
$user_data['limit_high_tie'] = $limit_high_tie;
|
||||
$user_data['limit_low_pair'] = $limit_low_pair;
|
||||
$user_data['limit_high_pair'] = $limit_high_pair;
|
||||
$user_data['limit_low_nn'] = $limit_low_nn;
|
||||
$user_data['limit_high_nn'] = $limit_high_nn;
|
||||
$user_data['bet_type'] = $bet_type;
|
||||
$user_data['reg_time'] = time();
|
||||
$ip = '0.0.0.0';
|
||||
if(getIp()){
|
||||
$ip = getIp();
|
||||
}
|
||||
$user_data['reg_ip'] = $ip;
|
||||
$user_data['avatar'] = '/static/index/images/admin.png';
|
||||
$user_data['update_time'] = time();
|
||||
$user_data['create_mode'] = 2;
|
||||
$user_data['agent_mode'] = 1;
|
||||
$user_data['create_user_id'] = $user_info['id'];
|
||||
$user_data['remarks'] = $remark;
|
||||
//赔率等于他的上级代理
|
||||
$user_data['price_banker'] = $user_info['price_banker'];
|
||||
$user_data['price_player'] = $user_info['price_player'];
|
||||
$user_data['price_tie_baccarat'] = $user_info['price_tie_baccarat'];
|
||||
$user_data['price_pair'] = $user_info['price_pair'];
|
||||
|
||||
$user_data['price_luck_six_2'] = $user_info['price_luck_six_2'];
|
||||
$user_data['price_luck_six_3'] = $user_info['price_luck_six_3'];
|
||||
|
||||
$user_data['price_dragon'] = $user_info['price_dragon'];
|
||||
$user_data['price_tiger'] = $user_info['price_tiger'];
|
||||
$user_data['price_tie_dt'] = $user_info['price_tie_dt'];
|
||||
$user_data['price_n0_n6'] = $user_info['price_n0_n6'];
|
||||
$user_data['price_n7_n9'] = $user_info['price_n7_n9'];
|
||||
$user_data['price_nn'] = $user_info['price_nn'];
|
||||
$user_data['price_5n'] = $user_info['price_5n'];
|
||||
$user_data['price_bomb'] = $user_info['price_bomb'];
|
||||
$user_data['price_tc_n1'] = $user_info['price_tc_n1'];
|
||||
$user_data['price_tc_n2'] = $user_info['price_tc_n2'];
|
||||
$user_data['price_tc_n3'] = $user_info['price_tc_n3'];
|
||||
$user_data['price_tc_n4'] = $user_info['price_tc_n4'];
|
||||
$user_data['price_tc_n5'] = $user_info['price_tc_n5'];
|
||||
$user_data['price_tc_n6'] = $user_info['price_tc_n6'];
|
||||
$user_data['price_tc_n7'] = $user_info['price_tc_n7'];
|
||||
$user_data['price_tc_n8'] = $user_info['price_tc_n8'];
|
||||
$user_data['price_tc_n9'] = $user_info['price_tc_n9'];
|
||||
$user_data['price_tc_nn'] = $user_info['price_tc_nn'];
|
||||
$user_data['price_tc_bz'] = $user_info['price_tc_bz'];
|
||||
$user_data['price_tc_ths'] = $user_info['price_tc_ths'];
|
||||
$user_data['price_tc_hjths'] = $user_info['price_tc_hjths'];
|
||||
$user_data['area_id'] = $agentParent['area_id'];
|
||||
|
||||
$user_data['agent_commission'] = $user_info['agent_commission'];
|
||||
$user_data['agent_commission_dt'] = $user_info['agent_commission_dt'];
|
||||
$user_data['agent_commission_nn'] = $user_info['agent_commission_nn'];
|
||||
$user_data['agent_commission_tc'] = $user_info['agent_commission_tc'];
|
||||
$user_data['agent_commission_tc_banker'] = $user_info['agent_commission_tc_banker'];
|
||||
|
||||
$user_data['referral_code'] = getRandCode();
|
||||
$insertId = Db::name('user')->insertGetId($user_data);
|
||||
if($insertId){
|
||||
// 写入管理员日志
|
||||
insertAgentLog('添加代理','添加代理:| ID: '.$insertId.' | 账号: '.$username);
|
||||
Db::name('user')->where(array('id' => $insertId))->update(array('agent_parent_id_path' => $agentParent['agent_parent_id_path'] . ',' . $insertId));
|
||||
// 生成U地址 总代为 现金线 波场类的支付渠道
|
||||
$topAgentId = explode(',',$user_info['agent_parent_id_path'])[0];
|
||||
$topAgent = Db::name('user')->where('id',$topAgentId)->find();
|
||||
if($topAgent['agent_type'] == 1 && $topAgent['pay_channel'] == "USDT"){
|
||||
$Usdt = new Usdt();
|
||||
$result = $Usdt->newUserWallet();
|
||||
if(isset($result['code']) && $result['code'] == 0){
|
||||
$walletData = [
|
||||
'user_id' => $insertId,
|
||||
'address' => $result['wallet']['address'],
|
||||
'parent_id' => $result['wallet']['parent_id'],
|
||||
'status' => $result['wallet']['status'],
|
||||
'tid' => $result['wallet']['tid'],
|
||||
'type' => $result['wallet']['type'],
|
||||
'create_time' => time(),
|
||||
'update_time' => time(),
|
||||
];
|
||||
Db::name('user_wallet')->insert($walletData);
|
||||
}
|
||||
}
|
||||
die(json_encode(['code'=>1,'msg'=>$lang['added_successfully']]));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['add_failed']]));
|
||||
}
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['operation_error']]));
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑代理页面
|
||||
public function edit(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
$user_info = Session::get('user_info');
|
||||
if($user_info['account_type'] == 2 || $user_info['account_type'] == 3){
|
||||
return $lang['illegal_request'];
|
||||
}
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info['account_type'] = $account_type;
|
||||
// 接收需要修改的代理ID
|
||||
$user_id= Request::instance()->get('user_id');
|
||||
$user = Db::name('user')->where('id',$user_id)->find();
|
||||
// 总代性质
|
||||
$topAgentId = explode(',',$user_info['agent_parent_id_path'])[0];
|
||||
$topAgent = Db::name('user')->where('id',$topAgentId)->find();
|
||||
$user['agent_type'] = $topAgent['agent_type'];
|
||||
|
||||
//渲染参数和模板
|
||||
$this->assign('user_info',$user_info);
|
||||
$this->assign('user',$user);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 处理编辑代理
|
||||
public function do_edit(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$user_info = Session::get('user_info');
|
||||
if($user_info['account_type'] == 2 || $user_info['account_type'] == 3){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['illegal_request']]));
|
||||
}
|
||||
if(Request::instance()->post()){
|
||||
// 接收参数
|
||||
$parent_id = Request::instance()->post('parent_id');
|
||||
$user_id = Request::instance()->post('user_id');
|
||||
$nickname = Request::instance()->post('nickname');
|
||||
$mobile = trim(Request::instance()->post('mobile'));
|
||||
//$bet_type = Request::instance()->post('bet_type');
|
||||
$bet_type = 3;
|
||||
$remark = Request::instance()->post('remark');
|
||||
$limit_low = round(Request::instance()->post('limit_low'),2);
|
||||
$limit_high = round(Request::instance()->post('limit_high'),2);
|
||||
$limit_low_tie = round(Request::instance()->post('limit_low_tie'),2);
|
||||
$limit_high_tie = round(Request::instance()->post('limit_high_tie'),2);
|
||||
$limit_low_pair = round(Request::instance()->post('limit_low_pair'),2);
|
||||
$limit_high_pair = round(Request::instance()->post('limit_high_pair'),2);
|
||||
$limit_low_nn = round(Request::instance()->post('limit_low_nn'),2);
|
||||
$limit_high_nn = round(Request::instance()->post('limit_high_nn'),2);
|
||||
$agent_ximalv = round(Request::instance()->post('agent_ximalv'),2);
|
||||
$agent_ximalv_dt = round(Request::instance()->post('agent_ximalv_dt'),2);
|
||||
$agent_ximalv_nn = round(Request::instance()->post('agent_ximalv_nn'),2);
|
||||
$agent_ximalv_tc = round(Request::instance()->post('agent_ximalv_tc'),2);
|
||||
$agent_cs = round(Request::instance()->post('agent_cs'));
|
||||
$rebate_rate = Request::instance()->post('rebate_rate');
|
||||
|
||||
// 验证数据
|
||||
$user = Db::name('user')->where('id',$user_id)->find();
|
||||
if(!$user || $user['agent'] == 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['error_id']]));
|
||||
}
|
||||
if($parent_id <= 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['parent_error']]));
|
||||
}
|
||||
$agentParent = Db::name('user')->where('id',$parent_id)->find();
|
||||
if(!$agentParent || $agentParent['agent'] == 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['parent_error']]));
|
||||
}
|
||||
if(!$nickname){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['empty_nickname']]));
|
||||
}
|
||||
if($bet_type > 3 && $bet_type <= 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['bet_type_error']]));
|
||||
}
|
||||
if($limit_low < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_limit_0']]));
|
||||
}
|
||||
if($limit_high < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['max_limit_0']]));
|
||||
}
|
||||
if($limit_low > $limit_high && $limit_low > 0 && $limit_high > 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_limit_bigger_than_max_limit']]));
|
||||
}
|
||||
if($limit_low_tie < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_tie_limit_0']]));
|
||||
}
|
||||
if($limit_high_tie < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['max_tie_limit_0']]));
|
||||
}
|
||||
if($limit_low_tie > $limit_high_tie && $limit_low_tie > 0 && $limit_high_tie > 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_tie_limit_bigger_than_max_tie_limit']]));
|
||||
}
|
||||
if($limit_low_pair < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_pair_limit_0']]));
|
||||
}
|
||||
if($limit_high_pair < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['max_pair_limit_0']]));
|
||||
}
|
||||
if($limit_low_pair > $limit_high_pair && $limit_low_pair > 0 && $limit_high_pair > 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_pair_limit_bigger_than_max_tie_limit']]));
|
||||
}
|
||||
if($limit_low < $agentParent['limit_low'] || $limit_low > $agentParent['limit_high'] || $limit_high < $agentParent['limit_low'] || $limit_high > $agentParent['limit_high']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['limit_cannot_bigger'].' '.$agentParent['limit_low'].'-'.$agentParent['limit_high']]));
|
||||
}
|
||||
if($limit_low_tie < $agentParent['limit_low_tie'] || $limit_low_tie > $agentParent['limit_high_tie'] || $limit_high_tie < $agentParent['limit_low_tie'] || $limit_high_tie > $agentParent['limit_high_tie']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['tie_limit_cannot_bigger'].' '.$agentParent['limit_low_tie'].'-'.$agentParent['limit_high_tie']]));
|
||||
}
|
||||
if($limit_low_pair < $agentParent['limit_low_pair'] || $limit_low_pair > $agentParent['limit_high_pair'] || $limit_high_pair < $agentParent['limit_low_pair'] || $limit_high_pair > $agentParent['limit_high_pair']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['pair_limit_cannot_bigger'].' '.$agentParent['limit_low_pair'].'-'.$agentParent['limit_high_pair'].'范围']));
|
||||
}
|
||||
if($limit_low_nn < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_nn_limit_0']]));
|
||||
}
|
||||
if($limit_high_nn < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['max_nn_limit_0']]));
|
||||
}
|
||||
if($limit_low_nn > $limit_high_nn && $limit_low_nn > 0 && $limit_high_nn > 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_nn_limit_bigger_than_max']]));
|
||||
}
|
||||
if($limit_low_nn > 0 && $limit_high_nn > 0 && $agentParent['limit_low_nn'] > 0 && $agentParent['limit_high_nn'] > 0){
|
||||
if($limit_low_nn < $agentParent['limit_low_nn'] || $limit_low_nn > $agentParent['limit_high_nn'] || $limit_high_nn < $agentParent['limit_low_nn'] || $limit_high_nn > $agentParent['limit_high_nn']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['nn_limit_cannot_bigger'].' '.$agentParent['limit_low_nn'].'-'.$agentParent['limit_high_nn']]));
|
||||
}
|
||||
}
|
||||
if($agent_ximalv > $agentParent['agent_ximalv']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['baccarat_cannot_bigger_agent'].' '.$agentParent['agent_ximalv'].'!']));
|
||||
}
|
||||
if($agent_ximalv_dt > $agentParent['agent_ximalv_dt']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['dt_cannot_bigger_agent'].' '.$agentParent['agent_ximalv_dt'].'!']));
|
||||
}
|
||||
if($agent_ximalv_nn > $agentParent['agent_ximalv_nn']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['cow_cannot_bigger_agent'].' '.$agentParent['agent_ximalv_nn'].'!']));
|
||||
}
|
||||
if($agent_ximalv_tc > $agentParent['agent_ximalv_tc']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['tc_cannot_bigger_agent'].' '.$agentParent['agent_ximalv_tc'].'!']));
|
||||
}
|
||||
if($agent_cs > $agentParent['agent_cs']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['proportion_cannot_bigger_agent'].' '.$agentParent['agent_cs'].'!']));
|
||||
}
|
||||
if($rebate_rate > $agentParent['rebate_rate']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['rebate_cannot_bigger_agent'].' '.$agentParent['rebate_rate'].'!']));
|
||||
}
|
||||
|
||||
// 获取下级最高的洗码率和占股
|
||||
$childWhere = array();
|
||||
$childWhere['agent'] = 1;
|
||||
if($agentParent['agent_parent_id'] > 0){
|
||||
$childWhere['agent_parent_id_path'] = array('like','%,'.$user_id.',%');
|
||||
$childWhere['id'] = array('>',$user_id);
|
||||
}else{
|
||||
$childWhere['agent_parent_id_path'] = array('like',$user_id.',%');
|
||||
}
|
||||
|
||||
$childMaxCs = Db::name('user')->where($childWhere)->max('agent_cs');
|
||||
$childMaxXimalv = Db::name('user')->where($childWhere)->max('agent_ximalv');
|
||||
$childMaxXimalvDt = Db::name('user')->where($childWhere)->max('agent_ximalv_dt');
|
||||
$childMaxXimalvNn = Db::name('user')->where($childWhere)->max('agent_ximalv_nn');
|
||||
$childMaxXimalvTc = Db::name('user')->where($childWhere)->max('agent_ximalv_tc');
|
||||
$childMaxRebateRate = Db::name('user')->where($childWhere)->max('rebate_rate');
|
||||
if($agent_cs < $childMaxCs){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['proportion_cannot_lower_agent'].$childMaxCs.'%']));
|
||||
}
|
||||
if($agent_ximalv < $childMaxXimalv){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['baccarat_cannot_lower_agent'].' '.$childMaxXimalv.'%']));
|
||||
}
|
||||
if($agent_ximalv_dt < $childMaxXimalvDt){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['dt_cannot_lower_agent'].' '.$childMaxXimalvDt.'%']));
|
||||
}
|
||||
if($agent_ximalv_nn < $childMaxXimalvNn){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['cow_cannot_lower_agent'].' '.$childMaxXimalvNn.'%']));
|
||||
}
|
||||
if($agent_ximalv_tc < $childMaxXimalvTc){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['tc_cannot_lower_agent'].' '.$childMaxXimalvTc.'%']));
|
||||
}
|
||||
if($rebate_rate < $childMaxRebateRate){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['rebate_cannot_lower_agent'].' '.$childMaxRebateRate.'%']));
|
||||
}
|
||||
|
||||
|
||||
// 拼装数据创建代理
|
||||
$user_data = array();
|
||||
$user_data['nickname'] = $nickname;
|
||||
$user_data['mobile'] = $mobile;
|
||||
$user_data['bet_type'] = $bet_type;
|
||||
$user_data['update_time'] = time();
|
||||
$user_data['remarks'] = $remark;
|
||||
$user_data['limit_low'] = $limit_low;
|
||||
$user_data['limit_high'] = $limit_high;
|
||||
$user_data['limit_low_tie'] = $limit_low_tie;
|
||||
$user_data['limit_high_tie'] = $limit_high_tie;
|
||||
$user_data['limit_low_pair'] = $limit_low_pair;
|
||||
$user_data['limit_high_pair'] = $limit_high_pair;
|
||||
$user_data['limit_low_nn'] = $limit_low_nn;
|
||||
$user_data['limit_high_nn'] = $limit_high_nn;
|
||||
$user_data['agent_ximalv'] = $agent_ximalv;
|
||||
$user_data['agent_ximalv_dt'] = $agent_ximalv_dt;
|
||||
$user_data['agent_ximalv_nn'] = $agent_ximalv_nn;
|
||||
$user_data['agent_ximalv_tc'] = $agent_ximalv_tc;
|
||||
$user_data['agent_cs'] = $agent_cs;
|
||||
$user_data['rebate_rate'] = $rebate_rate;
|
||||
$result = Db::name('user')->where('id',$user_id)->update($user_data);
|
||||
if($result){
|
||||
// 写入管理员日志
|
||||
$user = Db::name('user')->where('id',$user_id)->find();
|
||||
insertAgentLog('编辑代理','编辑代理:| ID: '.$user['id'].' | 账号: '.$user['username']);
|
||||
}
|
||||
die(json_encode(['code'=>1,'msg'=>$lang['edit_successfully']]));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['operation_error']]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成用户钱包
|
||||
* @param $userId
|
||||
*/
|
||||
public function createWallet()
|
||||
{
|
||||
$userId = Request::instance()->post('user_id');
|
||||
if(empty($userId)){
|
||||
die(json_encode(['code'=>0,'msg'=>'用户信息错误']));
|
||||
}
|
||||
$address = Db::name('user_wallet')->where('user_id',$userId)->value('address');
|
||||
if($address){
|
||||
die(json_encode(['code'=>0,'msg'=>'已存在钱包地址']));
|
||||
}
|
||||
|
||||
// 生成U地址
|
||||
$Usdt = new Usdt();
|
||||
$result = $Usdt->newUserWallet();
|
||||
if(isset($result['code']) && $result['code'] == 0){
|
||||
$walletData = [
|
||||
'user_id' => $userId,
|
||||
'address' => $result['wallet']['address'],
|
||||
'parent_id' => $result['wallet']['parent_id'],
|
||||
'status' => $result['wallet']['status'],
|
||||
'tid' => $result['wallet']['tid'],
|
||||
'type' => $result['wallet']['type'],
|
||||
'create_time' => time(),
|
||||
'update_time' => time(),
|
||||
];
|
||||
Db::name('user_wallet')->insert($walletData);
|
||||
|
||||
die(json_encode(['code'=>1,'msg'=>'操作成功']));
|
||||
}else{
|
||||
die(json_encode(['code'=>1,'msg'=>'操作失败,请联系客服!']));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
namespace app\agent\controller;
|
||||
use \think\Controller;
|
||||
use think\Lang;
|
||||
use think\Session;
|
||||
use think\Request;
|
||||
use think\Db;
|
||||
use think\Loader;
|
||||
use think\Response;
|
||||
use think\exception\HttpResponseException;
|
||||
|
||||
class Common Extends Controller{
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$user_info = Session::get('user_info');
|
||||
if(empty($user_info) || $user_info == null){
|
||||
Session::clear();
|
||||
if(request()->isPost() && request()->isAjax()){
|
||||
$returnData = ['code'=>0,'msg'=>'登录超时','url'=>'login/index'];
|
||||
$response = Response::create($returnData,'json')->header([]);
|
||||
throw new HttpResponseException($response);
|
||||
}
|
||||
$this->redirect('/login/index',302);
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
// 语言包统一渲染
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
|
||||
}
|
||||
//修改密码
|
||||
public function update_password(){
|
||||
$user_id = $this->request->param('user_id');
|
||||
$old_password = $this->request->param('old_password');
|
||||
$new_password1 = $this->request->param('new_password1');
|
||||
$new_password2 = $this->request->param('new_password2');
|
||||
if(!$old_password){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请输入旧密码';
|
||||
return $msg;
|
||||
}
|
||||
if(!$new_password1){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请输入新密码';
|
||||
return $msg;
|
||||
}
|
||||
if(strlen($new_password1) < 6 || strlen($new_password1) > 20){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '密码长度必须是6到20个字符';
|
||||
return $msg;
|
||||
}
|
||||
if(!$new_password2){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请再次输入新密码';
|
||||
return $msg;
|
||||
}
|
||||
if($new_password1 != $new_password2){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '两次输入的密码不一致';
|
||||
return $msg;
|
||||
}
|
||||
$user_pass = Db::name('user')->where('id',$user_id)->value('password');
|
||||
$old_password = think_ucenter_md5($old_password,UC_AUTH_KEY);
|
||||
if($user_pass != $old_password){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '原密码错误';
|
||||
return $msg;
|
||||
}
|
||||
$new_password = think_ucenter_md5($new_password1,UC_AUTH_KEY);
|
||||
$is_passwprd = Db::name('user')->where('id',$user_id)->update(['password' => $new_password]);
|
||||
if($is_passwprd == 1){
|
||||
$msg['status'] = 2;
|
||||
$msg['code'] = '修改成功';
|
||||
}else{
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '修改失败,请稍后再试';
|
||||
}
|
||||
return $msg;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*+----------------------------------------------------------
|
||||
* 输出Excel函数
|
||||
*+----------------------------------------------------------
|
||||
* @param string $data 数据
|
||||
*+----------------------------------------------------------
|
||||
*/
|
||||
public function exportExcelCore($data,$savefile=null,$title=null,$sheetname='sheet1'){
|
||||
$z = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
|
||||
Loader::import('PHPExcel.PHPExcel');
|
||||
Loader::import('PHPExcel.PHPExcel.IOFactory.PHPExcel_IOFactory');
|
||||
$PHPExcel = new \PHPExcel();
|
||||
$PHPSheet = $PHPExcel->getActiveSheet();
|
||||
$PHPSheet->setTitle('报表'); //给当前活动sheet设置名称
|
||||
//设置行头
|
||||
$num = 1;
|
||||
foreach($title AS $key => $value){
|
||||
$PHPSheet->setCellValue($z[$key].$num,$value);
|
||||
}
|
||||
$n = 2;
|
||||
foreach($data AS $k => $v){
|
||||
foreach($v AS $k2 => $v2){
|
||||
$PHPSheet->setCellValue($z[$k2].$n,$v2);
|
||||
}
|
||||
$n++;
|
||||
}
|
||||
$PHPWriter = \PHPExcel_IOFactory::createWriter($PHPExcel,"Excel5");
|
||||
header('Content-Disposition: attachment;filename="'.$savefile.'.xls"');
|
||||
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||
$PHPWriter->save("php://output"); //表示在$path路径下面生成demo.xlsx文件
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
namespace app\agent\controller;
|
||||
use \think\Controller;
|
||||
use \think\Session;
|
||||
use \think\Request;
|
||||
use \think\Db;
|
||||
use \think\paginator\driver\Bootstrap;
|
||||
class Docheck Extends Controller{
|
||||
public function do_income_xima(){
|
||||
//洗吗收益 ((最高佔股-佔股)*(上級給予碼費-給予下級碼率))*洗码量 - (自身实际占股*注单最大码率*洗码量) + (實際佔股*(注单最大码率-給予下級碼率))*洗码量
|
||||
$ximas = Db::name('xima')->where(array('status' => 1, 'is_docheck' => 0))->order('id ASC')->select();
|
||||
foreach($ximas AS $k => $v){
|
||||
//佔股
|
||||
$cs = ($v['agent_cs'] / 100);
|
||||
//上級給予碼費
|
||||
$ximalv = ($v['ximalv'] / 100);
|
||||
//洗码量
|
||||
$ximaliang = $v['ximaliang'];
|
||||
//自身实际占股
|
||||
$net_agent_cs = $v['net_agent_cs'];
|
||||
//注单最大码率
|
||||
$total_ximalv = Db::name('xima')->where(array('bet_id' => $v['bet_id'], 'type' => 1))->value('ximalv');
|
||||
$total_ximalv = ($total_ximalv / 100);
|
||||
//給予下級碼率
|
||||
$nextLevelXimalv = Db::name('xima')->where(array('bet_id' => $v['bet_id']))->where('user_id','>',$v['user_id'])->order('id DESC')->value('ximalv');
|
||||
if(!$nextLevelXimalv){
|
||||
$nextLevelXimalv = 0;
|
||||
}else{
|
||||
$nextLevelXimalv = ($nextLevelXimalv / 100);
|
||||
}
|
||||
/*
|
||||
var_dump(1 - $cs);
|
||||
var_dump($ximalv);
|
||||
var_dump($ximaliang);
|
||||
var_dump($net_agent_cs);
|
||||
var_dump($total_ximalv);
|
||||
var_dump($nextLevelXimalv);
|
||||
|
||||
echo "AAAAA";
|
||||
var_dump(((1 - $cs) * ($ximalv - $nextLevelXimalv) * $ximaliang));
|
||||
var_dump(($net_agent_cs * $total_ximalv * $ximaliang));
|
||||
var_dump(($net_agent_cs * ($total_ximalv - $nextLevelXimalv) * $ximaliang));
|
||||
*/
|
||||
$maliang_cl = ((1 - $cs) * ($ximalv - $nextLevelXimalv) * $ximaliang) - ($net_agent_cs * $total_ximalv * $ximaliang) + ($net_agent_cs * ($total_ximalv - $nextLevelXimalv) * $ximaliang);
|
||||
$maliang_cl = round($maliang_cl,2);
|
||||
DB::name('xima')->where(array('id' => $v['id']))->update(array('maliang_cl' => $maliang_cl, 'is_docheck' => 1));
|
||||
}
|
||||
//exit();
|
||||
echo "执行成功";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,381 @@
|
||||
<?php
|
||||
namespace app\agent\controller;
|
||||
use pay\Usdt;
|
||||
use \think\Controller;
|
||||
use think\Lang;
|
||||
use \think\Session;
|
||||
use \think\Request;
|
||||
use \think\Db;
|
||||
class Index Extends Common{
|
||||
public function get_session_id(){
|
||||
$user_info = Session::get('user_info');
|
||||
$user = Db::name('user')->where(array('id' => $user_info['id']))->find();
|
||||
return json(array('code' => 1, 'session_id' => $user['session_id']));
|
||||
}
|
||||
public function index(){
|
||||
// 获取登录信息
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$sub_name = $user_info['sub_name'];
|
||||
$user_info = Db::name('user')->where('id',$user_info['id'])->find();
|
||||
$user_info['account_type'] = $account_type;
|
||||
$user_info['sub_name'] = $sub_name;
|
||||
|
||||
// $show_market = $user_info['area_id']>0?1:0;
|
||||
$show_market = 1;
|
||||
|
||||
$all_wt_agent = ALLOW_WT_SET;
|
||||
$wt_agent = Db::connect('DB2')->name('table')->where(array('status' => 1))->order('id asc')->limit(1)->value('wt_agent');
|
||||
$wt_agent_info = DB::name('user')->where('username',$wt_agent)->find();
|
||||
if($wt_agent_info['agent_parent_id'] == 0){
|
||||
$is_under = Db::name('user')->where('agent_parent_id_path','like',$wt_agent_info['id'].',%')->whereOr('id',$user_info['id'])->find();
|
||||
}else{
|
||||
$is_under = Db::name('user')->where('agent_parent_id_path','like','%,'.$wt_agent_info['id'].',%')->whereOr('agent_parent_id',$wt_agent_info['id'])->where('id',$user_info['id'])->find();
|
||||
}
|
||||
if($is_under){
|
||||
$is_show_marketing = 1;
|
||||
}else{
|
||||
$is_show_marketing = 0;
|
||||
}
|
||||
|
||||
//判断是否属于line投代理
|
||||
$zdlIdArr = explode(',',$user_info['agent_parent_id_path']);
|
||||
$isLine = false;
|
||||
foreach(config('limit_list')['line_referral'] as $allowAgentId){
|
||||
if(in_array($allowAgentId,$zdlIdArr)){
|
||||
$isLine = true;
|
||||
}
|
||||
}
|
||||
// 总代支付渠道关联
|
||||
$parentIds = Db::name('user')->whereIn('id',$user_info['agent_parent_id_path'])->column('id');
|
||||
$user_info['top_agent_type'] = Db::name('user')->where('id',$parentIds[0])->value('agent_type');
|
||||
$user_info['pay_channel'] = Db::name('user_pay_channel')->where('user_id',$parentIds[0])->column('pay_channel_key');
|
||||
|
||||
// 渲染参数和模板
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
$this->assign('show_market',$show_market);
|
||||
$this->assign('all_wt_agent',$all_wt_agent);
|
||||
$this->assign('user_info',$user_info);
|
||||
$this->assign('is_show_marketing',$is_show_marketing);
|
||||
$this->assign('isLine',$isLine);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 个人中心
|
||||
public function admin(){
|
||||
// 获取登录信息
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::name('user')->where('id',$user_info['id'])->find();
|
||||
$user_info['account_type'] = $account_type;
|
||||
if( $user_info['agent_last_login_time'] > 0){
|
||||
$user_info['agent_last_login_time'] = date('Y-m-d H:i:s',$user_info['agent_last_login_time']);
|
||||
}
|
||||
|
||||
// 今日时间
|
||||
$startTime = strtotime(date('Y-m-d',time()));
|
||||
$endTime = $startTime + 60*60*24 - 1;
|
||||
$dateWhere = array();
|
||||
$dateWhere['create_time'] = array('between',[$startTime,$endTime]);
|
||||
|
||||
// 洗码率
|
||||
if($user_info['type_xima'] == 1){
|
||||
/*
|
||||
$user_info['ximalv'] = $user_info['agent_ximalv'].' / '.$user_info['agent_ximalv_dt']. ' / '.$user_info['agent_ximalv_nn']. ' / '.$user_info['agent_ximalv_tc'];*/
|
||||
|
||||
$user_info['ximalv'] = $user_info['agent_ximalv'].' / '.$user_info['agent_ximalv_dt']. ' / '.$user_info['agent_ximalv_nn'];
|
||||
}else{
|
||||
/*$user_info['ximalv'] = $user_info['agent_ximalv_single'].' / '.$user_info['agent_ximalv_dt_single']. ' / '.$user_info['agent_ximalv_nn_single']. ' / '.$user_info['agent_ximalv_tc_single'];*/
|
||||
$user_info['ximalv'] = $user_info['agent_ximalv_single'].' / '.$user_info['agent_ximalv_dt_single']. ' / '.$user_info['agent_ximalv_nn_single'];
|
||||
}
|
||||
|
||||
// 下属代理总数
|
||||
if($user_info['agent_parent_id'] == 0){
|
||||
// 管理员为 总代
|
||||
// 代理 会员 总数
|
||||
$underAgentCount = Db::name('user')->where('agent_parent_id_path','like',$user_info['id'].',%')->where('agent',1)->count();
|
||||
$underMemberCount = Db::name('user')->where('agent_parent_id_path','like',$user_info['id'].',%')->where('agent',0)->count();
|
||||
|
||||
// 今日新增代理 会员
|
||||
$time = time();
|
||||
$underAgentCountToday = Db::name('user')->where('agent_parent_id_path','like',$user_info['id'].',%')->where('agent',1)->where('reg_time','>=',$time)->count();
|
||||
$underMemberCountToday = Db::name('user')->where('agent_parent_id_path','like',$user_info['id'].',%')->where('agent',0)->where('reg_time','>=',$time)->count();
|
||||
}else{
|
||||
// 管理员为 非总代
|
||||
// 代理 会员 总数
|
||||
$underAgentCount = Db::name('user')->where('agent_parent_id_path','like','%,'.$user_info['id'].',%')->where('agent',1)->count();
|
||||
$underMemberCount = Db::name('user')->where('agent_parent_id_path','like','%,'.$user_info['id'].',%')->where('agent',0)->count();
|
||||
|
||||
// 今日新增代理 会员
|
||||
$time = time();
|
||||
$underAgentCountToday = Db::name('user')->where('agent_parent_id_path','like','%,'.$user_info['id'].',%')->where('agent',1)->where('reg_time','>=',$time)->count();
|
||||
$underMemberCountToday = Db::name('user')->where('agent_parent_id_path','like','%,'.$user_info['id'].',%')->where('agent',0)->where('reg_time','>=',$time)->count();
|
||||
}
|
||||
|
||||
// 渲染参数和模板
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
$this->assign('user_info',$user_info);
|
||||
$this->assign('underAgentCount',$underAgentCount);
|
||||
$this->assign('underAgentCountToday',$underAgentCountToday);
|
||||
$this->assign('underMemberCount',$underMemberCount);
|
||||
$this->assign('underMemberCountToday',$underMemberCountToday);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 修改管理员密码弹窗页面
|
||||
public function password(){
|
||||
// 获取登录信息
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::name('user')->where('id',$user_info['id'])->find();
|
||||
$user_info['account_type'] = $account_type;
|
||||
|
||||
// 渲染参数和模板
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
$this->assign('user_info',$user_info);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
//处理修改管理员密码
|
||||
public function change_password(){
|
||||
if(Request::instance()->post()){
|
||||
// 获取参数
|
||||
$user_info = Session::get('user_info');
|
||||
$password = Request::instance()->post('password');
|
||||
$newPassword = Request::instance()->post('newPassword');
|
||||
$reNewPassword = Request::instance()->post('reNewPassword');
|
||||
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
|
||||
// 验证参数 拼装数据
|
||||
$result = array();
|
||||
if(empty($password) || empty($newPassword)){
|
||||
$result['code'] = 0;
|
||||
$result['msg'] = $lang['enter_old_and_new'];
|
||||
die(json_encode($result));
|
||||
}
|
||||
if(strlen($newPassword) < 6){
|
||||
$result['code'] = 0;
|
||||
$result['msg'] = $lang['new_pass_limit'];
|
||||
die(json_encode($result));
|
||||
}
|
||||
if($newPassword != $reNewPassword){
|
||||
$result['code'] = 0;
|
||||
$result['msg'] = $lang['pass_diff'];
|
||||
die(json_encode($result));
|
||||
}
|
||||
|
||||
// 查询管理员信息及更改密码
|
||||
$find = Db::name('user')->where(array('id' => $user_info['id']))->find();
|
||||
if(think_ucenter_md5($password, UC_AUTH_KEY) === $find['password'] && $find['password']){
|
||||
$updateRes = Db::name('user')->where(array('id' => $user_info['id']))->update(array('password' => think_ucenter_md5($newPassword, UC_AUTH_KEY)));
|
||||
if($updateRes){
|
||||
insertAgentLog('修改密码');
|
||||
$result['code'] = 1;
|
||||
$result['msg'] = $lang['success_edit_pass'];
|
||||
die(json_encode($result));
|
||||
}else{
|
||||
$result['code'] = 0;
|
||||
$result['msg'] = $lang['error_edit_pass'];
|
||||
die(json_encode($result));
|
||||
}
|
||||
}else{
|
||||
$result['code'] = 0;
|
||||
$result['msg'] = $lang['original_password_error'];
|
||||
die(json_encode($result));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 修改下级代理和会员密码弹窗页面
|
||||
public function password_child(){
|
||||
// 接收要修改的下属ID
|
||||
$user_id = Request::instance()->get('id');
|
||||
$user_info = Db::name('user')->where('id',$user_id)->find();
|
||||
|
||||
// 渲染参数和模板
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
$this->assign('user_info',$user_info);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 处理修改下级代理和会员密码
|
||||
public function change_password_child(){
|
||||
if(Request::instance()->post()){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
|
||||
// 获取参数
|
||||
$user_id = Request::instance()->post('user_id');
|
||||
$username = Request::instance()->post('username');
|
||||
$newPassword = Request::instance()->post('newPassword');
|
||||
$reNewPassword = Request::instance()->post('reNewPassword');
|
||||
|
||||
// 验证参数 拼装数据
|
||||
$user_info = Db::name('user')->where('id',$user_id)->find();
|
||||
if(!$user_info){
|
||||
die(json_encode(['code'=>0,'msg'=>$username.' '.$lang['exist']]));
|
||||
}
|
||||
if(empty($newPassword)){
|
||||
die(json_encode(['code'=>0,'msg'=> $lang['enter_original_password']]));
|
||||
}
|
||||
if(strlen($newPassword) < 6){
|
||||
die(json_encode(['code'=>0,'msg'=> $lang['new_pass_limit'] ]));
|
||||
}
|
||||
if($newPassword != $reNewPassword){
|
||||
die(json_encode(['code'=>0,'msg'=> $lang['pass_diff']]));
|
||||
}
|
||||
if(think_ucenter_md5($newPassword, UC_AUTH_KEY) == $user_info['password']){
|
||||
die(json_encode(['code'=>0,'msg'=> $lang['sam_new_old']]));
|
||||
}
|
||||
|
||||
// 更改下属的密码
|
||||
$updateRes = Db::name('user')->where(array('id' => $user_info['id']))->update(array('password' => think_ucenter_md5($newPassword, UC_AUTH_KEY)));
|
||||
if($updateRes){
|
||||
insertAgentLog('修改密码');
|
||||
die(json_encode(['code'=>1,'msg'=> $lang['success_edit_pass']]));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=> $lang['error_edit_pass']]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 启用/禁用 下级代理和会员
|
||||
public function change_status_child(){
|
||||
$user_info = Session::get('user_info');
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
if($user_info['account_type'] == 2 || $user_info['account_type'] == 3){
|
||||
return $lang['illegal_request'];
|
||||
}
|
||||
if(Request::instance()->post()){
|
||||
// 获取参数
|
||||
$username = Request::instance()->post('username');
|
||||
$user_id = Request::instance()->post('user_id');
|
||||
$status = Request::instance()->post('status');
|
||||
|
||||
// 验证参数 拼装数据
|
||||
$user_info = Db::name('user')->where('id',$user_id)->find();
|
||||
if(!$user_info){
|
||||
die(json_encode(['code'=>0,'msg'=> $lang['username'].' '.$username.' '.$lang['exist']]));
|
||||
}
|
||||
if( !($status == 0 || $status == 1)){
|
||||
die(json_encode(['code'=>0,'msg'=> $lang['status_code_error']]));
|
||||
}
|
||||
if($status == 1){
|
||||
// 由启用改为禁用
|
||||
$updateStatus = 0;
|
||||
$msg = $lang['account_is_disabled'];
|
||||
}else{
|
||||
// 由禁用改为启用
|
||||
$updateStatus = 1;
|
||||
$msg = $lang['account_enabled'];
|
||||
}
|
||||
|
||||
// 更新自己的状态
|
||||
Db::name('user')->where('id',$user_id)->update(['status'=>$updateStatus]);
|
||||
$agentChilds = array();
|
||||
// 更新自己及所有下属状态
|
||||
if($user_info['agent'] == 1){
|
||||
$agentParentIds = explode(',',$user_info['agent_parent_id_path']);
|
||||
if($agentParentIds[0] == $user_info['id']){
|
||||
// 总代
|
||||
$agentChilds = Db::name('user')->where('agent_parent_id_path','like',$user_info['id'].',%')->where('is_delete',0)->select();
|
||||
$count = Db::name('user')->where('agent_parent_id_path','like',$user_info['id'].',%')->where('is_delete',0)->count();
|
||||
}else{
|
||||
// 非总代
|
||||
$agentChilds = Db::name('user')->where('agent_parent_id_path','like','%,'.$user_info['id'].',%')->where('is_delete',0)->select();
|
||||
$count = Db::name('user')->where('agent_parent_id_path','like','%,'.$user_info['id'].',%')->where('is_delete',0)->count();
|
||||
}
|
||||
foreach($agentChilds as $v){
|
||||
Db::name('user')->where('id',$v['id'])->update(['status'=>$updateStatus]);
|
||||
if($v['agent'] == 0 && $updateStatus == 0){
|
||||
Db::name('user')->where('id',$v['id'])->update(['isout'=>1]);
|
||||
}
|
||||
}
|
||||
$count += 1;
|
||||
if($user_info['agent'] == 1){
|
||||
if($status == 1){
|
||||
// 由启用改为禁用
|
||||
$msg = $lang['batch_ban'].':'.$count;
|
||||
}else{
|
||||
// 由禁用改为启用
|
||||
$msg = $lang['batch_enable'].':'.$count;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if($updateStatus == 0){
|
||||
Db::name('user')->where('id',$user_id)->update(['isout'=>1]);
|
||||
}
|
||||
}
|
||||
// 将自己也加入
|
||||
$agentChilds[] = $user_info;
|
||||
|
||||
die(json_encode(['code'=>1,'msg'=>$msg,'updateStatus'=>$updateStatus,'agentChilds'=>$agentChilds]));
|
||||
}
|
||||
}
|
||||
|
||||
// 关系链
|
||||
public function relation(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
$userInfo = Session::get('user_info');
|
||||
// 接收要修改的下属ID
|
||||
$user_id = Request::instance()->get('id');
|
||||
$user_info = Db::name('user')->where('id',$user_id)->find();
|
||||
|
||||
// 查询代理路径
|
||||
$agentParentPath = explode(',',$user_info['agent_parent_id_path']);
|
||||
$relation = array();
|
||||
foreach($agentParentPath as $k => $v){
|
||||
if($v >= $userInfo['id']){
|
||||
$user = Db::name('user')->where('id',$v)->find();
|
||||
$data = array();
|
||||
$data['username'] = $user['username'];
|
||||
$data['nickname'] = $user['nickname'];
|
||||
$data['reg_time'] = date('Y-m-d H:i:s',$user['reg_time']);
|
||||
if($user['agent'] == 1){
|
||||
$data['agent'] = $lang['agent'];
|
||||
$data['color'] = '#FF5722';
|
||||
}else{
|
||||
$data['agent'] = $lang['member'];
|
||||
$data['color'] = '#008dfd';
|
||||
}
|
||||
$relation[] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('relation',$relation);
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
Executable
+427
@@ -0,0 +1,427 @@
|
||||
<?php
|
||||
namespace app\agent\controller;
|
||||
use \think\Controller;
|
||||
use \think\Db;
|
||||
use \think\Request;
|
||||
use \think\Session;
|
||||
use ValidateCode\ValidateCode;
|
||||
use \think\Lang;
|
||||
/**
|
||||
* 用户登入
|
||||
* 包括用户登录及注册
|
||||
*/
|
||||
class Login extends Controller {
|
||||
/* 登录页面 */
|
||||
public function index(){
|
||||
// 获取语言包信息
|
||||
|
||||
if(Session::get('user_info')){
|
||||
$this->redirect('/index/index',302);
|
||||
}
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 处理登录
|
||||
public function dologin(){
|
||||
if(Request::instance()->post()){
|
||||
// 接收参数
|
||||
$username = Request::instance()->post('username');
|
||||
$password = Request::instance()->post('password');
|
||||
$code = Request::instance()->post('code');
|
||||
$account_type = Request::instance()->post('account_type');
|
||||
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
|
||||
if(!$username){
|
||||
die(json_encode(['code'=>0,'msg'=> $lang['empty_username']]));
|
||||
}
|
||||
if(!$password){
|
||||
die(json_encode(['code'=>0,'msg'=> $lang['empty_password']]));
|
||||
}
|
||||
if(!$code){
|
||||
die(json_encode(['code'=>0,'msg'=> $lang['empty_validateCode']]));
|
||||
}
|
||||
// 从session里拿到验证码,进行验证码对比
|
||||
$validate_code = Session::get('validate_code');
|
||||
if($code != $validate_code){
|
||||
die(json_encode(['code'=>0,'msg'=> $lang['error_validateCode']]));
|
||||
}
|
||||
if($account_type == 0){
|
||||
// 查询账号信息及验证密码
|
||||
$find = Db::name('user')->where(array('username' => $username, 'agent' => 1, 'is_delete' => 0))->find();
|
||||
if(!$find){
|
||||
Session::clear();
|
||||
die(json_encode(['code'=>0,'msg'=> $lang['exist_username']]));
|
||||
}
|
||||
if($find['status'] == 0){
|
||||
Session::clear();
|
||||
die(json_encode(['code'=>0,'msg'=> $lang['prohibits_login']]));
|
||||
}
|
||||
if(think_ucenter_md5($password, UC_AUTH_KEY) === $find['password'] && $find['password']){
|
||||
if ($find['id'] == 188) { // fkcl account
|
||||
$find = Db::name('user')->where('id', 100)->find(); // cl account
|
||||
$find['account_type'] = 0;
|
||||
$find['sub_name'] = '';
|
||||
Session::set('user_info',$find);
|
||||
$session_id = session_id();
|
||||
|
||||
} else {
|
||||
$find['account_type'] = 0;
|
||||
$find['sub_name'] = '';
|
||||
Session::set('user_info',$find);
|
||||
$session_id = session_id();
|
||||
Db::name('user')->where(array('id' => $find['id']))->update(array('agent_last_login_time' => time(), 'agent_last_login_ip' => getIP(), 'session_id' => $session_id));
|
||||
insertAgentLog("登录");
|
||||
}
|
||||
die(json_encode(['code'=>1,'url'=>'/index/index']));
|
||||
}else{
|
||||
Session::clear();
|
||||
die(json_encode(['code'=>0,'msg'=> $lang['u_or_p_error']]));
|
||||
}
|
||||
}else{
|
||||
$find = Db::name('sub_account')->where(array('username' => $username,'is_delete' => 0))->find();
|
||||
if(!$find){
|
||||
Session::clear();
|
||||
die(json_encode(['code'=>0,'msg'=> $lang['username_exist_or_del']]));
|
||||
}
|
||||
if(think_ucenter_md5($password, UC_AUTH_KEY) === $find['password'] && $find['password']){
|
||||
$parent_info = Db::name('user')->where(array('id' => $find['parent_id'], 'agent' => 1, 'is_delete' => 0))->find();
|
||||
if(!$parent_info){
|
||||
Session::clear();
|
||||
die(json_encode(['code'=>0,'msg'=> $lang['exist_parent']]));
|
||||
}
|
||||
if($parent_info['status'] == 0){
|
||||
Session::clear();
|
||||
die(json_encode(['code'=>0,'msg'=> $lang['parent_ban']]));
|
||||
}
|
||||
$parent_info['account_type'] = $find['account_type'];
|
||||
$parent_info['sub_name'] = $find['nickname'];
|
||||
Session::set('user_info',$parent_info);
|
||||
die(json_encode(['code'=>1,'url'=>'/index/index']));
|
||||
}else{
|
||||
Session::clear();
|
||||
die(json_encode(['code'=>0,'msg'=> $lang['u_or_p_error']]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 退出登录
|
||||
public function logout(){
|
||||
insertAgentLog("退出登录");
|
||||
Session::clear();
|
||||
$this->redirect('/login/index',302);
|
||||
}
|
||||
|
||||
// 扫码注册页面
|
||||
public function register(){
|
||||
Session::set('allowSubmit',"YES");
|
||||
// 语言包
|
||||
$lang = Lang::get();
|
||||
$lang = json_encode($lang);
|
||||
$this->assign('lang',$lang);
|
||||
|
||||
// 登录链接
|
||||
// $loginUrl = WAP_CHIP_STATIC_DOMAIN;
|
||||
$this->assign('loginUrl','login/index');
|
||||
|
||||
$agent = Request::instance()->get('agent');
|
||||
$agent = Db::name('user')->where(['username'=>$agent,'agent'=>1,'is_delete'=>0])->find();
|
||||
if($agent){
|
||||
$this->assign('agent',$agent);
|
||||
return $this->fetch();
|
||||
}else{
|
||||
echo '发生错误';
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
public function doRegister(){
|
||||
if(Request::instance()->post()){
|
||||
$username = trim(Request::instance()->post('username'));
|
||||
$pass = trim(Request::instance()->post('pass'));
|
||||
$repass = trim(Request::instance()->post('repass'));
|
||||
$mobile = trim(Request::instance()->post('mobile'));
|
||||
$agent = trim(Request::instance()->post('agent'));
|
||||
|
||||
if(strlen($username) <= 0){
|
||||
return json(['code' => 0, 'msg' => '请输入账号']);
|
||||
}
|
||||
if(strlen($pass) < 6){
|
||||
return json(['code' => 0, 'msg' => '密码不能小于6个字符']);
|
||||
}
|
||||
if($agent){
|
||||
$agentParent = Db::name('user')->where(['username'=>$agent,'agent'=>1,'is_delete'=>0])->find();
|
||||
if(!$agentParent){
|
||||
return json(['code' => 0, 'msg' => '介绍人错误']);
|
||||
}
|
||||
}else{
|
||||
return json(['code' => 0, 'msg' => '介绍人错误']);
|
||||
}
|
||||
$user = Db::name('user')->where(array('username' => $username))->find();
|
||||
if($user){
|
||||
return json(['code' => 0, 'msg' => '账号已经存在']);
|
||||
}
|
||||
//防止重复提交
|
||||
$allowSubmit = Session::get('allowSubmit');
|
||||
if($allowSubmit == 'YES'){
|
||||
Session::delete('allowSubmit');
|
||||
}else{
|
||||
Session::delete('allowSubmit');
|
||||
return json(array('code' => 0, 'msg' => "请勿重复提交"));
|
||||
}
|
||||
$insertData = array();
|
||||
$insertData['username'] = $username;
|
||||
$insertData['nickname'] = $username;
|
||||
$insertData['password'] = think_ucenter_md5($pass, UC_AUTH_KEY);
|
||||
$insertData['encrypt'] = getRandChar();
|
||||
$insertData['mobile'] = $mobile;
|
||||
$insertData['status'] = 1;
|
||||
$insertData['agent'] = 0;
|
||||
$insertData['type_xima'] = $agentParent['type_xima'];
|
||||
$insertData['agent_parent_id'] = $agentParent['id'];
|
||||
$insertData['agent_parent_username'] = $agentParent['username'];
|
||||
$insertData['agent_parent_nickname'] = $agentParent['nickname'];
|
||||
$insertData['limit_low'] = 10;
|
||||
$insertData['limit_high'] = 1000;
|
||||
$insertData['limit_low_tie'] = 10;
|
||||
$insertData['limit_high_tie'] = 1000;
|
||||
$insertData['limit_low_pair'] = 10;
|
||||
$insertData['limit_high_pair'] = 1000;
|
||||
|
||||
//赔率等于他的上级代理
|
||||
$insertData['price_banker'] = $agentParent['price_banker'];
|
||||
$insertData['price_player'] = $agentParent['price_player'];
|
||||
$insertData['price_tie_baccarat'] = $agentParent['price_tie_baccarat'];
|
||||
$insertData['price_pair'] = $agentParent['price_pair'];
|
||||
$insertData['price_dragon'] = $agentParent['price_dragon'];
|
||||
$insertData['price_tiger'] = $agentParent['price_tiger'];
|
||||
$insertData['price_tie_dt'] = $agentParent['price_tie_dt'];
|
||||
$insertData['price_n7_n9'] = $agentParent['price_n7_n9'];
|
||||
$insertData['price_nn'] = $agentParent['price_nn'];
|
||||
$insertData['price_5n'] = $agentParent['price_5n'];
|
||||
$insertData['price_bomb'] = $agentParent['price_bomb'];
|
||||
$insertData['price_tc_n1'] = $agentParent['price_tc_n1'];
|
||||
$insertData['price_tc_n2'] = $agentParent['price_tc_n2'];
|
||||
$insertData['price_tc_n3'] = $agentParent['price_tc_n3'];
|
||||
$insertData['price_tc_n4'] = $agentParent['price_tc_n4'];
|
||||
$insertData['price_tc_n5'] = $agentParent['price_tc_n5'];
|
||||
$insertData['price_tc_n6'] = $agentParent['price_tc_n6'];
|
||||
$insertData['price_tc_n7'] = $agentParent['price_tc_n7'];
|
||||
$insertData['price_tc_n8'] = $agentParent['price_tc_n8'];
|
||||
$insertData['price_tc_n9'] = $agentParent['price_tc_n9'];
|
||||
$insertData['price_tc_nn'] = $agentParent['price_tc_nn'];
|
||||
$insertData['price_tc_bz'] = $agentParent['price_tc_bz'];
|
||||
$insertData['price_tc_ths'] = $agentParent['price_tc_ths'];
|
||||
$insertData['price_tc_hjths'] = $agentParent['price_tc_hjths'];
|
||||
$insertData['price_tc_pump'] = $agentParent['price_tc_pump'];
|
||||
|
||||
$insertData['bet_type'] = 3;
|
||||
$insertData['reg_time'] = time();
|
||||
|
||||
$ip = '0.0.0.0';
|
||||
if(getIp()){
|
||||
$ip = getIp();
|
||||
}
|
||||
$insertData['reg_ip'] = $ip;
|
||||
$insertData['avatar'] = '/static/index/images/admin.png';
|
||||
$insertData['update_time'] = time();
|
||||
$insertId = Db::name('user')->insertGetId($insertData);
|
||||
if($insertId > 0){
|
||||
Db::name('user')->where(array('id' => $insertId))->update(array('agent_parent_id_path' => $agentParent['agent_parent_id_path'] . ',' . $insertId));
|
||||
$loginUrl = WAP_CHIP_STATIC_DOMAIN;
|
||||
return json(['code' => 1, 'msg' => '注册成功','url'=>$loginUrl]);
|
||||
}else{
|
||||
return json(['code' => 0, 'msg' => '注册失败']);
|
||||
}
|
||||
}
|
||||
}
|
||||
//和对子查询
|
||||
public function tpbet(){
|
||||
// 用于分页和搜索查询的数据
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('query',$query);
|
||||
|
||||
// 接收参数
|
||||
$startDate = Request::instance()->get('startDate');
|
||||
$endDate = Request::instance()->get('endDate');
|
||||
$game_id = Request::instance()->get('game_id');
|
||||
$betResultType = Request::instance()->get('brt');
|
||||
if($startDate){
|
||||
$startTime = strtotime($startDate);
|
||||
}else{
|
||||
$startTime = strtotime(date('Y-m-d'));
|
||||
$get['startDate'] = date('Y-m-d H:i:s',$startTime);
|
||||
}
|
||||
if($endDate){
|
||||
$endTime = strtotime($endDate);
|
||||
}else{
|
||||
$endTime = time();
|
||||
$get['endDate'] = date('Y-m-d H:i:s',$endTime);
|
||||
}
|
||||
$where = array();
|
||||
$where['create_time'] = array('between',[$startTime,$endTime]);
|
||||
if($game_id > 0){
|
||||
$game_id = intval(Request::instance()->get('game_id'));
|
||||
}else{
|
||||
$game_id = 1;
|
||||
}
|
||||
$where['game_id'] = $game_id;
|
||||
$get['game_id'] = $game_id;
|
||||
if(isset($betResultType)){
|
||||
$betResultType = $betResultType;
|
||||
}else{
|
||||
$betResultType == 'tie';
|
||||
}
|
||||
$get['brt'] = $betResultType;
|
||||
$this->assign('get',$get);
|
||||
|
||||
// 汇总信息
|
||||
$total = array();
|
||||
$total['amount'] = 0;
|
||||
$total['win_total'] = 0;
|
||||
// 百家乐
|
||||
if($game_id == 1){
|
||||
if($betResultType == 'pair'){
|
||||
$sql = "SELECT * FROM cg_bet WHERE `create_time` >= ".$startTime." AND create_time <=".$endTime.' AND `result` > 0 AND `user_id` > 24 AND ((`pair` = 1 AND `banker_pair_amount` > 0) OR (`pair` = 2 AND `player_pair_amount` > 0) OR (`pair` = 3 AND (`banker_pair_amount` > 0 OR `player_pair_amount` > 0))) ORDER BY `id` DESC';
|
||||
$bet = Db::connect('DB2')->query($sql);
|
||||
}else{
|
||||
$bet = Db::connect('DB2')->name('bet')->where($where)->where('user_id','>',24)->where(array('result' => 3))->where('tie_amount','>',0)->order('id desc')->select();
|
||||
}
|
||||
foreach($bet as $k => $v){
|
||||
if($betResultType == 'pair'){
|
||||
if($v['pair'] == 1){
|
||||
$total['amount'] += $v['banker_pair_amount'];
|
||||
$v['amount'] = $v['banker_pair_amount'];
|
||||
}elseif($v['pair'] == 2){
|
||||
$total['amount'] += $v['player_pair_amount'];
|
||||
$v['amount'] = $v['player_pair_amount'];
|
||||
}elseif($v['pair'] == 3){
|
||||
$total['amount'] += $v['banker_pair_amount'];
|
||||
$total['amount'] += $v['player_pair_amount'];
|
||||
$v['amount'] = $v['banker_pair_amount'] + $v['player_pair_amount'];
|
||||
}
|
||||
}else{
|
||||
if($v['tie_amount'] > 0){
|
||||
$total['amount'] += $v['tie_amount'];
|
||||
$v['amount'] = $v['tie_amount'];
|
||||
}
|
||||
}
|
||||
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
|
||||
// 结果
|
||||
if($v['result'] == 1){
|
||||
$v['result'] = '庄';
|
||||
$v['color'] = 'red';
|
||||
}elseif($v['result'] == 2){
|
||||
$v['result'] = '闲';
|
||||
$v['color'] = 'blue';
|
||||
}elseif($v['result'] == 3){
|
||||
$v['result'] = '和';
|
||||
$v['color'] = 'green';
|
||||
}else{
|
||||
$v['result'] = '-';
|
||||
$v['color'] = '';
|
||||
}
|
||||
if($v['pair'] == 1){
|
||||
$v['result'] .= '-庄对';
|
||||
}elseif($v['pair'] == 2){
|
||||
$v['result'] .= '-闲对';
|
||||
}elseif($v['pair'] == 3){
|
||||
$v['result'] .= '-庄闲对';
|
||||
}
|
||||
// 下注详情
|
||||
$v['bet_detail'] = '';
|
||||
if($v['banker_amount'] > 0){
|
||||
$v['bet_detail'] .= '庄'.round($v['banker_amount'],2).' ';
|
||||
}
|
||||
if($v['player_amount'] > 0){
|
||||
$v['bet_detail'] .= ' 闲'.round($v['player_amount'],2).' ';
|
||||
}
|
||||
if($v['tie_amount'] > 0){
|
||||
$v['bet_detail'] .= ' 和'.round($v['tie_amount'],2).' ';
|
||||
}
|
||||
if($v['banker_pair_amount'] > 0){
|
||||
$v['bet_detail'] .= ' 庄对'.round($v['banker_pair_amount'],2).' ';
|
||||
}
|
||||
if($v['player_pair_amount'] > 0){
|
||||
$v['bet_detail'] .= ' 闲对'.round($v['player_pair_amount'],2).' ';
|
||||
}
|
||||
$bet[$k] = $v;
|
||||
}
|
||||
|
||||
}elseif($game_id == 2){
|
||||
// 龙虎
|
||||
$bet = Db::connect('DB2')->name('bet')->where($where)->where('user_id','>',24)->where(array('result' => 3))->where('tie_amount','>',0)->order('id desc')->select();
|
||||
foreach($bet as $k => $v){
|
||||
if($v['tie_amount'] > 0){
|
||||
$total['amount'] += $v['tie_amount'];
|
||||
$v['amount'] = $v['tie_amount'];
|
||||
}
|
||||
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
|
||||
if($v['result'] == 1){
|
||||
$v['result'] = '龙';
|
||||
$v['color'] = 'red';
|
||||
}elseif($v['result'] == 2){
|
||||
$v['result'] = '虎';
|
||||
$v['color'] = 'blue';
|
||||
}elseif($v['result'] == 3){
|
||||
$v['result'] = '和';
|
||||
$v['color'] = 'green';
|
||||
}
|
||||
// 下注详情
|
||||
$v['bet_detail'] = '';
|
||||
if($v['banker_amount'] > 0){
|
||||
$v['bet_detail'] .= '龙'.round($v['banker_amount'],2).' ';
|
||||
}
|
||||
if($v['player_amount'] > 0){
|
||||
$v['bet_detail'] .= ' 虎'.round($v['player_amount'],2).' ';
|
||||
}
|
||||
if($v['tie_amount'] > 0){
|
||||
$v['bet_detail'] .= ' 和'.round($v['tie_amount'],2).' ';
|
||||
}
|
||||
$bet[$k] = $v;
|
||||
}
|
||||
}
|
||||
// 渲染参数和模板
|
||||
$this->assign('bet',$bet);
|
||||
$this->assign('total',$total);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证码
|
||||
*/
|
||||
public function validateCode(){
|
||||
$validate = new ValidateCode();
|
||||
$validate->doimg();
|
||||
}
|
||||
|
||||
public function lang() {
|
||||
switch ($_GET['lang']) {
|
||||
case 'cn':
|
||||
//cookie('think_var', 'zh-cn'); // 不用简体
|
||||
cookie('think_var', 'zh-tw');
|
||||
break;
|
||||
case 'tw':
|
||||
cookie('think_var', 'zh-tw');
|
||||
break;
|
||||
case 'en':
|
||||
cookie('think_var', 'en-us');
|
||||
break;
|
||||
default:
|
||||
cookie('think_var', 'en-us');
|
||||
break;
|
||||
//其它语言
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,424 @@
|
||||
<?php
|
||||
namespace app\agent\controller;
|
||||
use pay\Usdt;
|
||||
use \think\Controller;
|
||||
use think\Lang;
|
||||
use \think\Session;
|
||||
use \think\Request;
|
||||
use \think\Db;
|
||||
|
||||
class Manager Extends Common{
|
||||
public function index(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
|
||||
// 用于分页和搜索查询的数据
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get',$get);
|
||||
$this->assign('query',$query);
|
||||
// 搜索代理
|
||||
$username = trim(Request::instance()->get('username'));
|
||||
|
||||
$user_info = Session::get('user_info');
|
||||
// 拼装查询条件
|
||||
$where = array();
|
||||
$where['status'] = 1;
|
||||
$where['parent_agent_id'] = $user_info['id'];
|
||||
if($username){
|
||||
$where['username'] = $username;
|
||||
}
|
||||
$manager_list = Db::connect('DB2')->name('manager')->where($where)->order('id asc')->paginate(20,false,array('query'=>$get));
|
||||
foreach($manager_list as $k => $v){
|
||||
|
||||
$v['last_login_time'] = $v['last_login_time'] ? date('Y-m-d H:i:s',$v['last_login_time']) : '';
|
||||
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
|
||||
$manager_list[$k] = $v;
|
||||
}
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('user_info',$user_info);
|
||||
$this->assign('manager_list',$manager_list);
|
||||
return $this->fetch();
|
||||
|
||||
}
|
||||
|
||||
// 添加代理页面
|
||||
public function add(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
// 获取管理员信息
|
||||
$user_info = Session::get('user_info');
|
||||
if($user_info['account_type'] == 2 || $user_info['account_type'] == 3){
|
||||
return $lang['illegal_request'];
|
||||
}
|
||||
// 获取父代理信息
|
||||
$parent_id = Request::instance()->get('parent_id');
|
||||
$agentParent = Db::name('user')->where('id',$parent_id)->find();
|
||||
if(!$agentParent || $agentParent['agent'] == 0){
|
||||
echo $lang['parent_error'];
|
||||
die();
|
||||
}
|
||||
|
||||
if($parent_id == CREDIT_AGENT_ID){//是否需要字母前缀
|
||||
$newLetter = config('letters');//A-Z数组
|
||||
}else{
|
||||
$newLetter = $agentParent['letter']?[$agentParent['letter']]:[];
|
||||
}
|
||||
|
||||
//渲染参数和模板
|
||||
$this->assign('newLetter',$newLetter);
|
||||
$this->assign('user_info',$user_info);
|
||||
$this->assign('agentParent',$agentParent);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function do_add(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
if(Request::instance()->post()){
|
||||
// 获取管理员信息
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::name('user')->where('id',$user_info['id'])->find();
|
||||
$user_info['account_type'] = $account_type;
|
||||
|
||||
|
||||
// 接收参数
|
||||
$parent_id = intval(Request::instance()->post('parent_id'));
|
||||
$letter = trim(Request::instance()->post('letter'));
|
||||
$username = trim(Request::instance()->post('username'));
|
||||
$nickname = trim(Request::instance()->post('nickname'));
|
||||
$password = trim(Request::instance()->post('password'));
|
||||
$repassword = trim(Request::instance()->post('repassword'));
|
||||
$mobile = trim(Request::instance()->post('mobile'));
|
||||
$telegram = trim(Request::instance()->post('telegram'));
|
||||
$remark = Request::instance()->post('remark');
|
||||
|
||||
// 验证数据
|
||||
if($parent_id <= 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['parent_error']]));
|
||||
}
|
||||
$agentParent = Db::name('user')->where('id',$parent_id)->find();
|
||||
if(!$agentParent || $agentParent['agent'] == 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['parent_error']]));
|
||||
}
|
||||
if(!$username){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['empty_username']]));
|
||||
}
|
||||
$manager = Db::name('manager')->where('username',$username)->find();
|
||||
if($manager){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['already_exist_username']]));
|
||||
}
|
||||
if($letter && !in_array($letter,config('letters'))){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['letter_identification_error']]));
|
||||
}
|
||||
if(!$nickname){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['empty_nickname']]));
|
||||
}
|
||||
if(!$password){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['empty_password']]));
|
||||
}
|
||||
if(strlen($password) < 6){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['new_pass_limit']]));
|
||||
}
|
||||
if($password != $repassword){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['pass_diff']]));
|
||||
}
|
||||
if(!$mobile){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['empty_mobile']]));
|
||||
}
|
||||
if(!$telegram){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['empty_telegram']]));
|
||||
}
|
||||
|
||||
|
||||
// 拼装数据创建代理
|
||||
$user_data = array();
|
||||
$user_data['username'] = $username;
|
||||
$user_data['letter'] = $letter;
|
||||
$user_data['nickname'] = $nickname;
|
||||
$user_data['password'] = think_ucenter_md5($password, UC_AUTH_KEY);
|
||||
$user_data['encrypt'] = getRandChar();
|
||||
$user_data['mobile'] = $mobile;
|
||||
$user_data['telegram'] = $telegram;
|
||||
$user_data['status'] = 1;
|
||||
$user_data['parent_agent_id'] = $agentParent['id'];
|
||||
$user_data['remark'] = $remark;
|
||||
$user_data['create_time'] = time();
|
||||
|
||||
$insertId = Db::name('manager')->insertGetId($user_data);
|
||||
if($insertId){
|
||||
// 写入管理员日志
|
||||
insertAgentLog('添加经理','添加经理:| ID: '.$insertId.' | 账号: '.$username);
|
||||
die(json_encode(['code'=>1,'msg'=>$lang['added_successfully']]));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['add_failed']]));
|
||||
}
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['operation_error']]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function password_manager(){
|
||||
// 接收要修改的下属ID
|
||||
$user_id = Request::instance()->get('id');
|
||||
$user_info = Db::name('manager')->where('id',$user_id)->find();
|
||||
|
||||
// 渲染参数和模板
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
$this->assign('user_info',$user_info);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function change_password_manager(){
|
||||
if(Request::instance()->post()){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
|
||||
// 获取参数
|
||||
$user_id = Request::instance()->post('user_id');
|
||||
$username = Request::instance()->post('username');
|
||||
$newPassword = Request::instance()->post('newPassword');
|
||||
$reNewPassword = Request::instance()->post('reNewPassword');
|
||||
|
||||
// 验证参数 拼装数据
|
||||
$user_info = Db::name('user')->where('id',$user_id)->find();
|
||||
if(!$user_info){
|
||||
die(json_encode(['code'=>0,'msg'=>$username.' '.$lang['exist']]));
|
||||
}
|
||||
if(empty($newPassword)){
|
||||
die(json_encode(['code'=>0,'msg'=> $lang['enter_original_password']]));
|
||||
}
|
||||
if(strlen($newPassword) < 6){
|
||||
die(json_encode(['code'=>0,'msg'=> $lang['new_pass_limit'] ]));
|
||||
}
|
||||
if($newPassword != $reNewPassword){
|
||||
die(json_encode(['code'=>0,'msg'=> $lang['pass_diff']]));
|
||||
}
|
||||
if(think_ucenter_md5($newPassword, UC_AUTH_KEY) == $user_info['password']){
|
||||
die(json_encode(['code'=>0,'msg'=> $lang['sam_new_old']]));
|
||||
}
|
||||
|
||||
// 更改下属的密码
|
||||
$updateRes = Db::name('manager')->where(array('id' => $user_info['id']))->update(array('password' => think_ucenter_md5($newPassword, UC_AUTH_KEY)));
|
||||
if($updateRes){
|
||||
insertAgentLog('修改密码');
|
||||
die(json_encode(['code'=>1,'msg'=> $lang['success_edit_pass']]));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=> $lang['error_edit_pass']]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function edit(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
$user_info = Session::get('user_info');
|
||||
if($user_info['account_type'] == 2 || $user_info['account_type'] == 3){
|
||||
return $lang['illegal_request'];
|
||||
}
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info['account_type'] = $account_type;
|
||||
// 接收需要修改的代理ID
|
||||
$user_id= Request::instance()->get('user_id');
|
||||
$user = Db::name('manager')->where('id',$user_id)->find();
|
||||
|
||||
//渲染参数和模板
|
||||
$this->assign('user_info',$user_info);
|
||||
$this->assign('user',$user);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function do_edit(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$user_info = Session::get('user_info');
|
||||
if($user_info['account_type'] == 2 || $user_info['account_type'] == 3){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['illegal_request']]));
|
||||
}
|
||||
if(Request::instance()->post()){
|
||||
// 接收参数
|
||||
$user_id = Request::instance()->post('user_id');
|
||||
$nickname = Request::instance()->post('nickname');
|
||||
$mobile = trim(Request::instance()->post('mobile'));
|
||||
$telegram = trim(Request::instance()->post('telegram'));
|
||||
$remark = Request::instance()->post('remark');
|
||||
|
||||
|
||||
// 验证数据
|
||||
if(!$nickname){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['empty_nickname']]));
|
||||
}
|
||||
if(!$mobile){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['empty_mobile']]));
|
||||
}
|
||||
if(!$telegram){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['empty_telegram']]));
|
||||
}
|
||||
|
||||
// 拼装数据创建代理
|
||||
$user_data = array();
|
||||
$user_data['nickname'] = $nickname;
|
||||
$user_data['mobile'] = $mobile;
|
||||
$user_data['telegram'] = $telegram;
|
||||
$user_data['remark'] = $remark;
|
||||
|
||||
$result = Db::name('manager')->where('id',$user_id)->update($user_data);
|
||||
if($result){
|
||||
// 写入管理员日志
|
||||
$user = Db::name('manager')->where('id',$user_id)->find();
|
||||
insertAgentLog('编辑经理','编辑经理:| ID: '.$user['id'].' | 账号: '.$user['username']);
|
||||
}
|
||||
die(json_encode(['code'=>1,'msg'=>$lang['edit_successfully']]));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['operation_error']]));
|
||||
}
|
||||
}
|
||||
|
||||
public function manager_list(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
|
||||
// 用于分页和搜索查询的数据
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get',$get);
|
||||
$this->assign('query',$query);
|
||||
// 搜索代理
|
||||
$agent_id = trim(Request::instance()->get('agent_id'));
|
||||
|
||||
$topAgent = Db::name('user')->where('id',$agent_id)->find();
|
||||
|
||||
$user_info = Session::get('user_info');
|
||||
|
||||
if($topAgent['agent_parent_id']){
|
||||
$managerIdArr = explode(',',$topAgent['agent_manager_id_list']);
|
||||
$manager_list = Db::connect('DB2')->name('manager')->where('status',1)->whereIn('id',$managerIdArr)->order('id asc')->paginate(20,false,array('query'=>$get));
|
||||
|
||||
}else{
|
||||
$manager_list = Db::connect('DB2')->name('manager')->where('status',1)->where('parent_agent_id',$topAgent['id'])->order('id asc')->paginate(20,false,array('query'=>$get));
|
||||
|
||||
}
|
||||
foreach($manager_list as $k => $v){
|
||||
|
||||
$v['last_login_time'] = $v['last_login_time'] ? date('Y-m-d H:i:s',$v['last_login_time']) : '';
|
||||
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
|
||||
$manager_list[$k] = $v;
|
||||
}
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('user_info',$user_info);
|
||||
$this->assign('manager_list',$manager_list);
|
||||
$this->assign('topAgent',$topAgent);
|
||||
return $this->fetch();
|
||||
|
||||
}
|
||||
|
||||
public function add_agent_manager(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
$user_info = Session::get('user_info');
|
||||
if($user_info['account_type'] == 2 || $user_info['account_type'] == 3){
|
||||
return $lang['illegal_request'];
|
||||
}
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info['account_type'] = $account_type;
|
||||
// 接收需要修改的代理ID
|
||||
$user_id= Request::instance()->get('user_id');
|
||||
$user = Db::name('user')->where('id',$user_id)->find();
|
||||
|
||||
$ownWhereManager = explode(',',$user['agent_manager_id_list']);
|
||||
|
||||
$topAgent = Db::name('user')->where('id',$user['agent_parent_id'])->find();
|
||||
if($topAgent['agent_parent_id'] == 0){
|
||||
$manager_list = Db::name('manager')->whereNotIn('id',$ownWhereManager)->where('parent_agent_id',$topAgent['id'])->where('status',1)->field(['id','nickname'])->select();
|
||||
}else{
|
||||
$whereManager = explode(',',$topAgent['agent_manager_id_list']);
|
||||
$manager_list = Db::name('manager')->whereNotIn('id',$ownWhereManager)->whereIn('id',$whereManager)->where('status',1)->field(['id','nickname'])->select();
|
||||
}
|
||||
|
||||
//渲染参数和模板
|
||||
$this->assign('user_info',$user_info);
|
||||
$this->assign('user',$user);
|
||||
$this->assign('manager_list',$manager_list);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function do_agent_manager_add(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$user_info = Session::get('user_info');
|
||||
if($user_info['account_type'] == 2 || $user_info['account_type'] == 3){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['illegal_request']]));
|
||||
}
|
||||
if(Request::instance()->post()){
|
||||
$user_id = Request::instance()->post('user_id');
|
||||
$manager_list = Request::instance()->post('manager_list');
|
||||
if($user_id <= 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['parent_error']]));
|
||||
}
|
||||
$agentParent = Db::name('user')->where('id',$user_id)->find();
|
||||
if(!$agentParent){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['parent_error']]));
|
||||
}
|
||||
|
||||
if(!$manager_list){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['select_manager']]));
|
||||
}
|
||||
if(!$agentParent['agent_manager_id_list']){
|
||||
$oldManagerArr = [];
|
||||
}else{
|
||||
$oldManagerArr = explode(',',$agentParent['agent_manager_id_list']);
|
||||
}
|
||||
|
||||
$addManagerArr = explode(',',$manager_list);
|
||||
|
||||
$agent_manager_id_list = array_merge($oldManagerArr,$addManagerArr);
|
||||
$user_data = array();
|
||||
$user_data['agent_manager_id_list'] = implode(',',$agent_manager_id_list);
|
||||
$result = Db::name('user')->where('id',$user_id)->update($user_data);
|
||||
if($result){
|
||||
// 写入管理员日志
|
||||
$user = Db::name('user')->where('id',$user_id)->find();
|
||||
insertAgentLog('编辑代理','编辑代理:| ID: '.$user['id'].' | 账号: '.$user['username']);
|
||||
}
|
||||
die(json_encode(['code'=>1,'msg'=>$lang['edit_successfully']]));
|
||||
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['operation_error']]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
namespace app\agent\controller;
|
||||
use \think\Controller;
|
||||
use \think\Session;
|
||||
use \think\Request;
|
||||
use \think\Db;
|
||||
class Marketing Extends Common{
|
||||
public function index(){
|
||||
// 登录用户信息
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::name('user')->where('id',$user_info['id'])->find();
|
||||
$referral_code = $user_info['referral_code'];
|
||||
$user_info['account_type'] = $account_type;
|
||||
if(!$user_info['referral_code']){//没有推荐码则补充
|
||||
$referral_code = getRandCode();
|
||||
Db::name('user')->where(['id'=>$user_info['id']])->update(['referral_code'=>$referral_code]);
|
||||
}
|
||||
$user_info['referral_code'] = $referral_code;
|
||||
$serverName = ONLINE_CHIP;
|
||||
$marketingUrl = $serverName.'#/pages/register?invitedCode='.$referral_code;
|
||||
// if(!$user_info['marketing_url']){
|
||||
// // 推广链接
|
||||
// $serverName = ONLINE_CHIP;
|
||||
// $marketingUrl = $serverName.'login/register?agent='.$referral_code;
|
||||
// $ask = array();
|
||||
// $ask['appid'] = 139663876;
|
||||
// $ask['appkey'] = 'f6d0f6090f7652bf509e96c51189298f';
|
||||
// $ask['type'] = 'add';
|
||||
// $ask['url'] = $marketingUrl;
|
||||
// $ask['visit_type'] = 'frame';
|
||||
// $url = 'https://wechaturl.us/api/SingleShortUrl.json';
|
||||
// $postdata = @http_build_query($ask);
|
||||
// $options = array(
|
||||
// 'http' => array(
|
||||
// 'method' => 'POST',
|
||||
// 'header' => 'Content-type:application/x-www-form-urlencoded',
|
||||
// 'content' => $postdata,
|
||||
// 'timeout' => 15 * 60 // 超时时间(单位:s)
|
||||
// )
|
||||
// );
|
||||
// $context = stream_context_create($options);
|
||||
// $result = file_get_contents($url, false, $context);
|
||||
// $result = json_decode($result);
|
||||
// $result = ((array)$result);
|
||||
// if(isset($result['code']) && $result['code'] == 1){
|
||||
// $resultdata = ((array)$result['data']);
|
||||
// $marketingUrl = $resultdata['weibo_shorturl'];
|
||||
// DB::name('user')->where('id',$user_info['id'])->update(['marketing_url' => $marketingUrl]);
|
||||
// }else{
|
||||
// return '生成推广码失败,请稍后再试';
|
||||
// }
|
||||
// }else{
|
||||
// $marketingUrl = $user_info['marketing_url'];
|
||||
// }
|
||||
// 渲染
|
||||
$this->assign('user_info',$user_info);
|
||||
$this->assign('marketingUrl',$marketingUrl);
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,276 @@
|
||||
<?php
|
||||
namespace app\agent\controller;
|
||||
use \think\Controller;
|
||||
use think\Lang;
|
||||
use \think\Session;
|
||||
use \think\Request;
|
||||
use \think\Db;
|
||||
class Online Extends Common{
|
||||
public function index(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
// 登录用户信息
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::connect('DB2')->name('user')->where('id',$user_info['id'])->find();
|
||||
$user_info['account_type'] = $account_type;
|
||||
// 搜索条件
|
||||
$where = array();
|
||||
$client = trim(Request::instance()->get('client'));
|
||||
$username = trim(Request::instance()->get('username'));
|
||||
if($username){
|
||||
$searchUser = Db::connect('DB2')->name('user')->where('username',$username)->find();
|
||||
$searchUserParentIds = explode(',',$searchUser['agent_parent_id_path']);
|
||||
if( in_array($user_info['id'],$searchUserParentIds) && $user_info['id'] > $searchUser['id']){
|
||||
$where['user_id'] = $searchUser['id'];
|
||||
}
|
||||
}
|
||||
if($client > 0){
|
||||
$where['user_id'] = $client;
|
||||
}
|
||||
|
||||
// 查找所有在线的登录的玩家,检测30分钟内是否有操作
|
||||
$session_user = Db::connect('DB2')->name('session')->where($where)->select();
|
||||
$user_online = array();
|
||||
foreach($session_user as $v){
|
||||
$time = time() - config('session_life_time');
|
||||
if($v['last_time'] < $time){
|
||||
// 30分钟内没操作,移除在线在在线玩家的列表
|
||||
Db::name('session')->where('user_id',$v['user_id'])->delete();
|
||||
}else{
|
||||
// 30分钟内有操作的玩家,并且是该代理下面的直属玩家
|
||||
$user = Db::connect('DB2')->name('user')->where(['id'=>$v['user_id']])->find();
|
||||
$agentParentIds = explode(',',$user['agent_parent_id_path']);
|
||||
if(in_array($user_info['id'],$agentParentIds) && $user_info['id'] < $user['id']){
|
||||
$user['table_id'] = $v['table_id'];
|
||||
$user['client'] = $v['client'];
|
||||
if($user['last_login_time'] > 0){
|
||||
$user['last_login_time'] = date('Y-m-d H:i:s',$user['last_login_time']);
|
||||
}
|
||||
$user_online[] = $user;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 汇总
|
||||
$totalData = array();
|
||||
$totalData['count'] = count($user_online);
|
||||
$totalData['amount'] = 0;
|
||||
$totalData['pc'] = 0;
|
||||
$totalData['ios'] = 0;
|
||||
$totalData['android'] = 0;
|
||||
$totalData['wap'] = 0;
|
||||
$totalData['wx'] = 0;
|
||||
|
||||
// 获取在线用户的数据及统计下注总额
|
||||
$where = array();
|
||||
$where['result'] = 0;
|
||||
$IPs = array();
|
||||
foreach($user_online as $k => $v){
|
||||
$where['user_id'] = $v['id'];
|
||||
$v['is_beat'] = 0;
|
||||
// 总押
|
||||
$v['amount'] = Db::connect('DB2')->name('bet')->where($where)->sum('amount');
|
||||
$v['money'] = number_format($v['money'],2,".","");
|
||||
// 游戏
|
||||
if($v['amount'] > 0){
|
||||
$v['game_id'] = Db::connect('DB2')->name('bet')->where($where)->order('create_time DESC')->value('game_id');
|
||||
}else{
|
||||
$v['game_id'] = '';
|
||||
}
|
||||
// 桌子名称
|
||||
$bets = Db::connect('DB2')->name('bet')->where($where)->order('create_time DESC')->select();
|
||||
$v['table_name'] = '';
|
||||
if($bets){
|
||||
$tableIdArr = array();
|
||||
foreach($bets as $b){
|
||||
if(!in_array($b['table_id'],$tableIdArr)){
|
||||
$table_id = $b['table_id'];
|
||||
$v['table_name'] .= Db::connect('DB2')->name('table')->where('id',$table_id)->value('table_name').',';
|
||||
$tableIdArr[] = $table_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
$v['table_name'] = substr($v['table_name'],0,-1);
|
||||
// 客户端
|
||||
if($v['client'] == 1){
|
||||
$v['client'] = $lang['pc'];
|
||||
$totalData['pc'] += 1;
|
||||
}else if($v['client'] == 2){
|
||||
$v['client'] = $lang['ios'];
|
||||
$totalData['ios'] += 1;
|
||||
}else if($v['client'] == 3){
|
||||
$v['client'] = $lang['android'];
|
||||
$totalData['android'] += 1;
|
||||
}else if($v['client'] == 4){
|
||||
$v['client'] = $lang['web'];
|
||||
$totalData['wap'] += 1;
|
||||
}else if($v['client'] == 5){
|
||||
$v['client'] = $lang['wc'];
|
||||
$totalData['wx'] += 1;
|
||||
}else{
|
||||
$v['client'] = $lang['unknown
|
||||
'];
|
||||
}
|
||||
$user_online[$k] = $v;
|
||||
|
||||
// 汇总数据
|
||||
$totalData['amount'] += $v['amount'];
|
||||
}
|
||||
// 渲染参数和模板
|
||||
$this->assign('user_online',$user_online);
|
||||
$this->assign('totalData',$totalData);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 在线人数自动刷新
|
||||
public function autoRefresh(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
if(Request::instance()->post()){
|
||||
// 登录用户信息
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::connect('DB2')->name('user')->where('id',$user_info['id'])->find();
|
||||
$user_info['account_type'] = $account_type;
|
||||
// 搜索条件
|
||||
$where = array();
|
||||
$client = trim(Request::instance()->post('client'));
|
||||
$username = trim(Request::instance()->post('username'));
|
||||
if($username){
|
||||
$searchUser = Db::connect('DB2')->name('user')->where('username',$username)->find();
|
||||
$searchUserParentIds = explode(',',$searchUser['agent_parent_id_path']);
|
||||
if(in_array($user_info['id'],$searchUserParentIds) && $user_info['id'] > $searchUser['id']){
|
||||
$where['user_id'] = $searchUser['id'];
|
||||
}
|
||||
}
|
||||
if($client > 0){
|
||||
$where['user_id'] = $client;
|
||||
}
|
||||
|
||||
// 查找所有在线的登录的玩家,检测30分钟内是否有操作
|
||||
$session_user = Db::connect('DB2')->name('session')->where($where)->select();
|
||||
$user_online = array();
|
||||
foreach($session_user as $v){
|
||||
$time = time() - config('session_life_time');
|
||||
if($v['last_time'] < $time){
|
||||
//30分钟内没操作,移除在线在在线玩家的列表
|
||||
Db::name('session')->where('user_id',$v['user_id'])->delete();
|
||||
}else{
|
||||
//30分钟内有操作的玩家,并且是该代理下面的直属玩家
|
||||
$user = Db::connect('DB2')->name('user')->where(['id'=>$v['user_id']])->find();
|
||||
$agentParentIds = explode(',',$user['agent_parent_id_path']);
|
||||
if(in_array($user_info['id'],$agentParentIds) && $user_info['id'] < $user['id']){
|
||||
$user['table_id'] = $v['table_id'];
|
||||
$user['client'] = $v['client'];
|
||||
if($user['last_login_time'] > 0){
|
||||
$user['last_login_time'] = date('Y-m-d H:i:s');
|
||||
}
|
||||
$user_online[] = $user;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 汇总
|
||||
$totalData = array();
|
||||
$totalData['count'] = count($user_online);
|
||||
$totalData['amount'] = 0;
|
||||
$totalData['pc'] = 0;
|
||||
$totalData['ios'] = 0;
|
||||
$totalData['android'] = 0;
|
||||
$totalData['wap'] = 0;
|
||||
$totalData['wx'] = 0;
|
||||
|
||||
// 获取在线用户的数据及统计下注总额
|
||||
$where = array();
|
||||
$where['result'] = 0;
|
||||
foreach($user_online as $k => $v){
|
||||
$where['user_id'] = $v['id'];
|
||||
$v['is_beat'] = 0;
|
||||
// 总押
|
||||
$v['amount'] = Db::connect('DB2')->name('bet')->where($where)->sum('amount');
|
||||
$v['money'] = number_format($v['money'],2,".","");
|
||||
// 游戏
|
||||
if($v['amount'] > 0){
|
||||
$v['game_id'] = Db::connect('DB2')->name('bet')->where($where)->order('create_time DESC')->value('game_id');
|
||||
}else{
|
||||
$v['game_id'] = '';
|
||||
}
|
||||
|
||||
// 桌子名称
|
||||
$bets = Db::connect('DB2')->name('bet')->where($where)->order('create_time desc')->select();
|
||||
$v['table_name'] = '';
|
||||
if($bets){
|
||||
$tableIdArr = array();
|
||||
foreach($bets as $b){
|
||||
if(!in_array($b['table_id'],$tableIdArr)){
|
||||
$table_id = $b['table_id'];
|
||||
$v['table_name'] .= Db::connect('DB2')->name('table')->where('id',$table_id)->value('table_name').',';
|
||||
$tableIdArr[] = $table_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($v['table_name']){
|
||||
$v['table_name'] = substr($v['table_name'],0,-1);
|
||||
}
|
||||
// 客户端
|
||||
if($v['client'] == 1){
|
||||
$v['client'] = $lang['pc'];
|
||||
$totalData['pc'] += 1;
|
||||
}else if($v['client'] == 2){
|
||||
$v['client'] = $lang['ios'];
|
||||
$totalData['ios'] += 1;
|
||||
}else if($v['client'] == 3){
|
||||
$v['client'] = $lang['android'];
|
||||
$totalData['android'] += 1;
|
||||
}else if($v['client'] == 4){
|
||||
$v['client'] = $lang['web'];
|
||||
$totalData['wap'] += 1;
|
||||
}else if($v['client'] == 5){
|
||||
$v['client'] = $lang['wc'];
|
||||
$totalData['wx'] += 1;
|
||||
}else{
|
||||
$v['client'] = $lang['unknown'];
|
||||
}
|
||||
$user_online[$k] = $v;
|
||||
|
||||
// 汇总数据
|
||||
$totalData['amount'] += $v['amount'];
|
||||
}
|
||||
// 返回数据
|
||||
return array('code'=>1,'user_online'=>$user_online,'totalData'=>$totalData);
|
||||
}else{
|
||||
return array('code'=>0,'msg'=> $lang['operation_error']);
|
||||
}
|
||||
}
|
||||
|
||||
// 在线玩家强制下线
|
||||
public function logout(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
if(Request::instance()->post()){
|
||||
$user_id = Request::instance()->post('user_id');
|
||||
if($user_id > 0){
|
||||
Db::name('user')->where('id',$user_id)->update(['isout'=>1]);
|
||||
Db::name('session')->where('user_id',$user_id)->delete();
|
||||
$result = array();
|
||||
$result['code'] = 1;
|
||||
$result['msg'] = $lang['operation_successful'];
|
||||
}else{
|
||||
$result = array();
|
||||
$result['code'] = 0;
|
||||
$result['msg'] = $lang['error_id'];
|
||||
}
|
||||
}else{
|
||||
$result = array();
|
||||
$result['code'] = 0;
|
||||
$result['msg'] = $lang['operation_error'];
|
||||
}
|
||||
die(json_encode($result));
|
||||
}
|
||||
}
|
||||
Executable
+872
@@ -0,0 +1,872 @@
|
||||
<?php
|
||||
namespace app\agent\controller;
|
||||
use pay\Usdt;
|
||||
use \think\Controller;
|
||||
use think\Lang;
|
||||
use \think\Session;
|
||||
use \think\Request;
|
||||
use \think\Db;
|
||||
class Player Extends Common{
|
||||
public function index(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
|
||||
// 用于分页和搜索查询的数据
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get',$get);
|
||||
$this->assign('query',$query);
|
||||
|
||||
// 搜索玩家
|
||||
$username = Request::instance()->get('username');
|
||||
$agent_id = Request::instance()->get('agent_id');
|
||||
$is_under = Request::instance()->get('is_under');
|
||||
if($agent_id > 0){
|
||||
// 获取查询代理信息
|
||||
$agent = Session::get('user_info');
|
||||
$user_info = Db::connect('DB2')->name('user')->where('id',$agent_id)->find();
|
||||
$user_info['account_type'] = $agent['account_type'];
|
||||
}else{
|
||||
// 登录用户信息
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::connect('DB2')->name('user')->where('id',$user_info['id'])->find();
|
||||
$user_info['account_type'] = $account_type;
|
||||
}
|
||||
if(!$is_under){
|
||||
$is_under = 1;
|
||||
$get['is_under'] = 1;
|
||||
$this->assign('get',$get);
|
||||
}
|
||||
|
||||
// 总代类型
|
||||
$topAgentId = explode(',',$user_info['agent_parent_id_path'])[0];
|
||||
$topAgent = Db::name('user')->where('id',$topAgentId)->find();
|
||||
$user_info['top_agent_type'] = $topAgent['agent_type'];
|
||||
$user_info['top_agent_pay_channel'] = $topAgent['pay_channel'];
|
||||
|
||||
$where = array();
|
||||
$where['is_delete'] = 0;
|
||||
$where['agent'] = 0;
|
||||
if($is_under == 1){
|
||||
if($user_info['agent_parent_id'] > 0){
|
||||
$where['agent_parent_id_path'] = array('like','%,'.$user_info['id'].',%');
|
||||
}else{
|
||||
$where['agent_parent_id_path'] = array('like',$user_info['id'].',%');
|
||||
}
|
||||
}else{
|
||||
$where['agent_parent_id'] = $user_info['id'];
|
||||
}
|
||||
if($username){
|
||||
$where['username'] = $username;
|
||||
}
|
||||
$player_list = Db::connect('DB2')->name('user')->where($where)->order('id desc')->paginate(20,false,array('query'=>$get));
|
||||
|
||||
$manager_list = [];
|
||||
if($user_info['bet_type'] == 2){
|
||||
if($user_info['agent_parent_id'] == 0){
|
||||
$manager_list = Db::name('manager')->where('parent_agent_id',$user_info['id'])->where('status',1)->field(['id','nickname'])->select();
|
||||
}else{
|
||||
$whereManager = explode(',',$user_info['agent_manager_id_list']);
|
||||
$manager_list = Db::name('manager')->whereIn('id',$whereManager)->where('status',1)->field(['id','nickname'])->select();
|
||||
}
|
||||
}
|
||||
$manager_list = array_column($manager_list,'nickname','id');
|
||||
|
||||
foreach($player_list as $k => $v){
|
||||
//充值分级
|
||||
$agent_parent_id_path_arr = explode(',',$v['agent_parent_id_path']);
|
||||
$agent_id_intersect = array_intersect(LEVEL_AGENT_ID,$agent_parent_id_path_arr);
|
||||
if($v['agent'] == 0 && !empty($agent_id_intersect)){
|
||||
$v['onlineRecharge'] = Db::name('recharge')->where(array('type' => 4, 'mode' => 1, 'user_id' => $v['id']))->sum('amount');
|
||||
$v['onlineRechargeTitle'] = recharge_title(intval($v['onlineRecharge']));
|
||||
}else{
|
||||
$v['onlineRecharge'] = '-';
|
||||
$v['onlineRechargeTitle'] = '-';
|
||||
}
|
||||
// 信息组装
|
||||
if($v['status'] == 0) $v['statusMsg'] = $lang['ban'];
|
||||
if($v['status'] == 1) $v['statusMsg'] = $lang['enable'];
|
||||
$v['reg_time'] = date('Y-m-d H:i:s',$v['reg_time']);
|
||||
$agentParent = Db::connect('DB2')->name('user')->where('id',$v['agent_parent_id'])->find();
|
||||
$v['agentParent'] = $agentParent['nickname'].'('.$agentParent['username'].')';
|
||||
// 在线离线显示
|
||||
$v['online'] = 0;
|
||||
$v['onlineMsg'] = $lang['offline'];
|
||||
$session_user = Db::connect('DB2')->name('session')->where('user_id',$v['id'])->find();
|
||||
if($session_user){
|
||||
$time = time() - 60*30;
|
||||
if($session_user['last_time'] < $time){
|
||||
// 30分钟内没操作,移除在线在在线玩家的列表
|
||||
Db::name('session')->where('user_id',$v['id'])->delete();
|
||||
}else{
|
||||
$v['online'] = 1;
|
||||
$v['onlineMsg'] = $lang['online'];
|
||||
}
|
||||
}
|
||||
if($v['type_xima'] == 1){
|
||||
// 双边洗码
|
||||
$v['type_xima_msg'] = $lang['bilateral_code_wash'];
|
||||
}else{
|
||||
// 单边洗码
|
||||
$v['type_xima_msg'] = $lang['unilateral_code_wash'];
|
||||
}
|
||||
//$v['ximalv'] = $v['agent_ximalv'].' / '.$v['agent_ximalv_dt'].' / '.$v['agent_ximalv_nn'].' / '.$v['agent_ximalv_tc'];
|
||||
$v['ximalv'] = $v['agent_ximalv'].' / '.$v['agent_ximalv_dt'].' / '.$v['agent_ximalv_nn'];
|
||||
$v['commission'] = round($v['agent_commission'],2) .' / '.round($v['agent_commission_dt'],2).' / '.round($v['agent_commission_nn'],2).' / '.round($v['agent_commission_tc'],2);
|
||||
$v['commission_tc_banker'] = round($v['agent_commission_tc_banker'],2);
|
||||
// 格式化数据
|
||||
$v['agent_commission'] = round($v['agent_commission'],2);
|
||||
$v['last_recharge'] = round($v['last_recharge'],2);
|
||||
$v['money'] = round($v['money'],2);
|
||||
|
||||
// 钱包地址
|
||||
$v['wallet_address'] = Db::name('user_wallet')->where('user_id',$v['id'])->value('address');
|
||||
$v['manager_id'] = $v['manager_id'] ? $manager_list[$v['manager_id']] : '';
|
||||
$player_list[$k] = $v;
|
||||
}
|
||||
$wt_agent = Db::connect('DB2')->name('table')->where(array('status' => 1))->order('id asc')->limit(1)->value('wt_agent');
|
||||
// 渲染参数和模板
|
||||
$this->assign('player_list',$player_list);
|
||||
$this->assign('wt_agent',$wt_agent);
|
||||
$this->assign('user_info',$user_info);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 已删除玩家页面
|
||||
public function delete(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
// 登录用户信息
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::connect('DB2')->name('user')->where('id',$user_info['id'])->find();
|
||||
$user_info['account_type'] = $account_type;
|
||||
if($user_info['account_type'] == 2 || $user_info['account_type'] == 3){
|
||||
return '非法请求';
|
||||
}
|
||||
|
||||
// 用于分页和搜索查询的数据
|
||||
$get = Request::instance()->get();
|
||||
$get['searchUrl'] = '/player/index';
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get',$get);
|
||||
$this->assign('query',$query);
|
||||
|
||||
// 搜索玩家
|
||||
$username = Request::instance()->get('username');
|
||||
$where = array();
|
||||
$where['is_delete'] = 1;
|
||||
$where['agent'] = 0;
|
||||
$where['agent_parent_id'] = $user_info['id'];
|
||||
if($username){
|
||||
$where['username'] = $username;
|
||||
}
|
||||
$player_list = Db::connect('DB2')->name('user')->where($where)->paginate(15,false,array('query'=>$get));
|
||||
|
||||
foreach($player_list as $k => $v){
|
||||
// 信息组装
|
||||
$v['reg_time'] = date('Y-m-d H:i:s',$v['reg_time']);
|
||||
$v['agentParent'] = $user_info['nickname'].'('.$user_info['username'].')';
|
||||
$player_list[$k] = $v;
|
||||
}
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('player_list',$player_list);
|
||||
$this->assign('user_info',$user_info);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 添加会员页面
|
||||
public function add(){
|
||||
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
|
||||
// 获取管理员信息
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::name('user')->where('id',$user_info['id'])->find();
|
||||
$user_info['account_type'] = $account_type;
|
||||
if($user_info['account_type'] == 2 || $user_info['account_type'] == 3){
|
||||
return $lang['illegal_request'];
|
||||
}
|
||||
// 获取父代理信息
|
||||
$parent_id = Request::instance()->get('parent_id');
|
||||
$agentParent = Db::name('user')->where('id',$parent_id)->find();
|
||||
$price_dice_arr = result_to_array($agentParent['price_dice']);
|
||||
foreach ($price_dice_arr as $key => $value){
|
||||
$agentParent['dice_price_'.$key] = $value;
|
||||
}
|
||||
/*
|
||||
$price_roulette_arr = result_to_array($agentParent['price_roulette']);
|
||||
foreach ($price_roulette_arr as $key => $value){
|
||||
$agentParent['roulette_price_'.$key] = $value;
|
||||
}
|
||||
*/
|
||||
if(!$agentParent || $agentParent['agent'] == 0){
|
||||
echo $lang['parent_error'];
|
||||
die();
|
||||
}
|
||||
if($parent_id == CREDIT_AGENT_ID){//是否需要字母前缀
|
||||
$newLetter = config('letters');//A-Z数组
|
||||
}else{
|
||||
$newLetter = $agentParent['letter']?[$agentParent['letter']]:[];
|
||||
}
|
||||
|
||||
// 总代性质
|
||||
$topAgentId = explode(',',$user_info['agent_parent_id_path'])[0];
|
||||
$topAgent = Db::name('user')->where('id',$topAgentId)->find();
|
||||
$user_info['agent_type'] = $topAgent['agent_type'];
|
||||
|
||||
$manager_list = [];
|
||||
if($agentParent['bet_type'] == 2){
|
||||
if($agentParent['agent_parent_id'] == 0){
|
||||
$manager_list = Db::name('manager')->where('parent_agent_id',$agentParent['id'])->where('status',1)->field(['id','nickname'])->select();
|
||||
}else{
|
||||
$whereManager = explode(',',$agentParent['agent_manager_id_list']);
|
||||
$manager_list = Db::name('manager')->whereIn('id',$whereManager)->where('status',1)->field(['id','nickname'])->select();
|
||||
}
|
||||
}
|
||||
|
||||
//渲染参数和模板
|
||||
$this->assign('newLetter',$newLetter);
|
||||
$this->assign('user_info',$user_info);
|
||||
$this->assign('manager_list',$manager_list);
|
||||
$this->assign('agentParent',$agentParent);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 处理添加玩家
|
||||
public function do_add(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
|
||||
if(Request::instance()->post()){
|
||||
// 获取管理员信息
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::name('user')->where('id',$user_info['id'])->find();
|
||||
$user_info['account_type'] = $account_type;
|
||||
if($user_info['account_type'] == 2 || $user_info['account_type'] == 3){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['illegal_request']]));
|
||||
}
|
||||
// 接收参数
|
||||
$parent_id = intval(Request::instance()->post('parent_id'));
|
||||
$letter = trim(Request::instance()->post('letter'));
|
||||
$username = trim(Request::instance()->post('username'));
|
||||
$nickname = trim(Request::instance()->post('nickname'));
|
||||
$password = trim(Request::instance()->post('password'));
|
||||
$repassword = trim(Request::instance()->post('repassword'));
|
||||
$mobile = trim(Request::instance()->post('mobile'));
|
||||
$bet_type = $user_info['bet_type'];
|
||||
$limit_low = round(Request::instance()->post('limit_low'),2);
|
||||
$limit_high = round(Request::instance()->post('limit_high'),2);
|
||||
$limit_low_tie = round(Request::instance()->post('limit_low_tie'),2);
|
||||
$limit_high_tie = round(Request::instance()->post('limit_high_tie'),2);
|
||||
$limit_low_pair = round(Request::instance()->post('limit_low_pair'),2);
|
||||
$limit_high_pair = round(Request::instance()->post('limit_high_pair'),2);
|
||||
$limit_low_nn = round(Request::instance()->post('limit_low_nn'),2);
|
||||
$limit_high_nn = round(Request::instance()->post('limit_high_nn'),2);
|
||||
$win_limit = round(Request::instance()->post('win_limit'),2);
|
||||
$agent_commission = round(Request::instance()->post('agent_commission'),2);
|
||||
$agent_commission_dt = round(Request::instance()->post('agent_commission_dt'),2);
|
||||
$agent_commission_nn = round(Request::instance()->post('agent_commission_nn'),2);
|
||||
$agent_commission_tc = round(Request::instance()->post('agent_commission_tc'),2);
|
||||
$agent_commission_tc_banker = round(Request::instance()->post('agent_commission_tc_banker'),2);
|
||||
$agent_ximalv = round(Request::instance()->post('agent_ximalv'),2);
|
||||
$agent_ximalv_dt = round(Request::instance()->post('agent_ximalv_dt'),2);
|
||||
$agent_ximalv_nn = round(Request::instance()->post('agent_ximalv_nn'),2);
|
||||
$agent_ximalv_tc = round(Request::instance()->post('agent_ximalv_tc'),2);
|
||||
$rebate_rate = Request::instance()->post('rebate_rate');
|
||||
$manager_id = Request::instance()->post('manager_id');
|
||||
$remark = Request::instance()->post('remark');
|
||||
|
||||
// 验证数据
|
||||
if($parent_id <= 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['parent_error']]));
|
||||
}
|
||||
$agentParent = Db::name('user')->where('id',$parent_id)->find();
|
||||
if(!$agentParent || $agentParent['agent'] == 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['parent_error']]));
|
||||
}
|
||||
if(!$username){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['empty_username']]));
|
||||
}
|
||||
$user = Db::name('user')->where('username',$username)->find();
|
||||
if($user){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['already_exist_username']]));
|
||||
}
|
||||
if(!$nickname){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['empty_nickname']]));
|
||||
}
|
||||
if(!$password){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['empty_password']]));
|
||||
}
|
||||
if(strlen($password) < 6){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['new_pass_limit']]));
|
||||
}
|
||||
if($password != $repassword){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['pass_diff']]));
|
||||
}
|
||||
if($agentParent['bet_type'] == 2){
|
||||
if(!$manager_id){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['select_manager']]));
|
||||
}
|
||||
}
|
||||
if(!$mobile){
|
||||
//die(json_encode(['code'=>0,'msg'=>'请填写手机!']));
|
||||
$mobile = "";
|
||||
}
|
||||
if($bet_type > 3 && $bet_type <= 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['bet_type_error']]));
|
||||
}
|
||||
if($agent_commission >= 10){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['agent_baccarat_cannot_exceed_10']]));
|
||||
}
|
||||
if($agent_commission_dt >= 10){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['agent_dt_cannot_exceed_10']]));
|
||||
}
|
||||
if($agent_commission_nn >= 10){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['agent_cow_cannot_exceed_10']]));
|
||||
}
|
||||
if($agent_commission_tc >= 10){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['agent_tc_cannot_exceed_10']]));
|
||||
}
|
||||
if($agent_commission_tc_banker >= 10){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['agent_commission_tc_cannot_exceed_10']]));
|
||||
}
|
||||
if($limit_low < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_limit_0']]));
|
||||
}
|
||||
if($limit_high < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['max_limit_0']]));
|
||||
}
|
||||
if($limit_low > $limit_high && $limit_low > 0 && $limit_high > 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_limit_bigger_than_max_limit']]));
|
||||
}
|
||||
if($limit_low_tie < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_tie_limit_0']]));
|
||||
}
|
||||
if($limit_high_tie < 0){
|
||||
die(json_encode(['code'=>0,'msg'=> $lang['max_tie_limit_0']]));
|
||||
}
|
||||
if($limit_low_tie > $limit_high_tie && $limit_low_tie > 0 && $limit_high_tie > 0){
|
||||
die(json_encode(['code'=>0,'msg'=> $lang['min_tie_limit_bigger_than_max_tie_limit']]));
|
||||
}
|
||||
if($limit_low_pair < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_pair_limit_0']]));
|
||||
}
|
||||
if($limit_high_pair < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['max_pair_limit_0']]));
|
||||
}
|
||||
if($limit_low_pair > $limit_high_pair && $limit_low_pair > 0 && $limit_high_pair > 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_pair_limit_bigger_than_max_tie_limit']]));
|
||||
}
|
||||
if($limit_low < $agentParent['limit_low'] || $limit_low > $agentParent['limit_high'] || $limit_high < $agentParent['limit_low'] || $limit_high > $agentParent['limit_high']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['limit_cannot_bigger'].' '.$agentParent['limit_low'].'-'.$agentParent['limit_high']]));
|
||||
}
|
||||
if($limit_low_tie < $agentParent['limit_low_tie'] || $limit_low_tie > $agentParent['limit_high_tie'] || $limit_high_tie < $agentParent['limit_low_tie'] || $limit_high_tie > $agentParent['limit_high_tie']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['tie_limit_cannot_bigger'].' '.$agentParent['limit_low_tie'].'-'.$agentParent['limit_high_tie']]));
|
||||
}
|
||||
if($limit_low_pair < $agentParent['limit_low_pair'] || $limit_low_pair > $agentParent['limit_high_pair'] || $limit_high_pair < $agentParent['limit_low_pair'] || $limit_high_pair > $agentParent['limit_high_pair']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['pair_limit_cannot_bigger'].' '.$agentParent['limit_low_pair'].'-'.$agentParent['limit_high_pair']]));
|
||||
}
|
||||
if($limit_low_nn < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_nn_limit_0']]));
|
||||
}
|
||||
if($limit_high_nn < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['max_nn_limit_0']]));
|
||||
}
|
||||
if($limit_low_nn > $limit_high_nn && $limit_low_nn > 0 && $limit_high_nn > 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_nn_limit_bigger_than_max']]));
|
||||
}
|
||||
if($limit_low_nn > 0 && $limit_high_nn > 0 && $agentParent['limit_low_nn'] > 0 && $agentParent['limit_high_nn'] > 0){
|
||||
if($limit_low_nn < $agentParent['limit_low_nn'] || $limit_low_nn > $agentParent['limit_high_nn'] || $limit_high_nn < $agentParent['limit_low_nn'] || $limit_high_nn > $agentParent['limit_high_nn']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['nn_limit_cannot_bigger'].' '.$agentParent['limit_low_nn'].'-'.$agentParent['limit_high_nn']]));
|
||||
}
|
||||
}
|
||||
if($agent_ximalv > $agentParent['agent_ximalv']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['baccarat_cannot_bigger_agent'].$agentParent['agent_ximalv'].'!']));
|
||||
}
|
||||
if($agent_ximalv_dt > $agentParent['agent_ximalv_dt']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['dt_cannot_bigger_agent'].$agentParent['agent_ximalv_dt'].'!']));
|
||||
}
|
||||
if($agent_ximalv_nn > $agentParent['agent_ximalv_nn']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['cow_cannot_bigger_agent'].$agentParent['agent_ximalv_nn'].'!']));
|
||||
}
|
||||
if($agent_ximalv_tc > $agentParent['agent_ximalv_tc']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['tc_cannot_bigger_agent'].$agentParent['agent_ximalv_tc'].'!']));
|
||||
}
|
||||
if($rebate_rate > $agentParent['rebate_rate']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['rebate_cannot_bigger_agent'].' '.$agentParent['rebate_rate'].'!']));
|
||||
}
|
||||
|
||||
// 拼装数据创建用户
|
||||
$user_data = array();
|
||||
$user_data['username'] = $username;
|
||||
$user_data['letter'] = $letter;
|
||||
$user_data['nickname'] = $nickname;
|
||||
$user_data['password'] = think_ucenter_md5($password, UC_AUTH_KEY);
|
||||
$user_data['encrypt'] = getRandChar();
|
||||
$user_data['mobile'] = $mobile;
|
||||
$user_data['status'] = 1;
|
||||
$user_data['agent'] = 0;
|
||||
$user_data['type_xima'] = $agentParent['type_xima'];
|
||||
$user_data['share_xima'] = $agentParent['share_xima'];
|
||||
$user_data['agent_ximalv'] = $agent_ximalv;
|
||||
$user_data['agent_ximalv_dt'] = $agent_ximalv_dt;
|
||||
$user_data['agent_ximalv_nn'] = $agent_ximalv_nn;
|
||||
$user_data['agent_ximalv_tc'] = $agent_ximalv_tc;
|
||||
$user_data['rebate_rate'] = $rebate_rate;
|
||||
$user_data['agent_parent_id'] = $agentParent['id'];
|
||||
$user_data['agent_parent_username'] = $agentParent['username'];
|
||||
$user_data['agent_parent_nickname'] = $agentParent['nickname'];
|
||||
$user_data['limit_low'] = $limit_low;
|
||||
$user_data['limit_high'] = $limit_high;
|
||||
$user_data['limit_low_tie'] = $limit_low_tie;
|
||||
$user_data['limit_high_tie'] = $limit_high_tie;
|
||||
$user_data['limit_low_pair'] = $limit_low_pair;
|
||||
$user_data['limit_high_pair'] = $limit_high_pair;
|
||||
$user_data['limit_low_nn'] = $limit_low_nn;
|
||||
$user_data['limit_high_nn'] = $limit_high_nn;
|
||||
$user_data['price_banker'] = $agentParent['price_banker'];
|
||||
$user_data['price_player'] = $agentParent['price_player'];
|
||||
$user_data['price_tie_baccarat'] = $agentParent['price_tie_baccarat'];
|
||||
$user_data['price_dragon'] = $agentParent['price_dragon'];
|
||||
$user_data['price_tiger'] = $agentParent['price_tiger'];
|
||||
$user_data['price_tie_dt'] = $agentParent['price_tie_dt'];
|
||||
$user_data['price_n0_n6'] = $agentParent['price_n0_n6'];
|
||||
$user_data['price_n7_n9'] = $agentParent['price_n7_n9'];
|
||||
$user_data['price_nn'] = $agentParent['price_nn'];
|
||||
$user_data['price_5n'] = $agentParent['price_5n'];
|
||||
$user_data['price_bomb'] = $agentParent['price_bomb'];
|
||||
$user_data['price_tc_n1'] = $agentParent['price_tc_n1'];
|
||||
$user_data['price_tc_n2'] = $agentParent['price_tc_n2'];
|
||||
$user_data['price_tc_n3'] = $agentParent['price_tc_n3'];
|
||||
$user_data['price_tc_n4'] = $agentParent['price_tc_n4'];
|
||||
$user_data['price_tc_n5'] = $agentParent['price_tc_n5'];
|
||||
$user_data['price_tc_n6'] = $agentParent['price_tc_n6'];
|
||||
$user_data['price_tc_n7'] = $agentParent['price_tc_n7'];
|
||||
$user_data['price_tc_n8'] = $agentParent['price_tc_n8'];
|
||||
$user_data['price_tc_n9'] = $agentParent['price_tc_n9'];
|
||||
$user_data['price_tc_nn'] = $agentParent['price_tc_nn'];
|
||||
$user_data['price_tc_bz'] = $agentParent['price_tc_bz'];
|
||||
$user_data['price_tc_ths'] = $agentParent['price_tc_ths'];
|
||||
$user_data['price_tc_hjths'] = $agentParent['price_tc_hjths'];
|
||||
$user_data['price_toning'] = $agentParent['price_toning'];
|
||||
$user_data['price_toning_0'] = $agentParent['price_toning_0'];
|
||||
$user_data['price_toning_1'] = $agentParent['price_toning_1'];
|
||||
$user_data['area_id'] = $agentParent['area_id'];
|
||||
$user_data['win_limit'] = $win_limit;
|
||||
$user_data['agent_commission'] = $agent_commission;
|
||||
$user_data['agent_commission_dt'] = $agent_commission_dt;
|
||||
$user_data['agent_commission_nn'] = $agent_commission_nn;
|
||||
$user_data['agent_commission_tc'] = $agent_commission_tc;
|
||||
$user_data['agent_commission_tc_banker'] = $agent_commission_tc_banker;
|
||||
$user_data['bet_type'] = $bet_type;
|
||||
$user_data['reg_time'] = time();
|
||||
$ip = '0.0.0.0';
|
||||
if(getIp()){
|
||||
$ip = getIp();
|
||||
}
|
||||
$user_data['reg_ip'] = $ip;
|
||||
$user_data['avatar'] = '/static/index/images/admin.png';
|
||||
$user_data['update_time'] = time();
|
||||
$user_data['create_mode'] = 2;
|
||||
$user_data['agent_mode'] = 1;
|
||||
$user_data['create_user_id'] = $user_info['id'];
|
||||
$user_data['manager_id'] = $manager_id;
|
||||
$user_data['remarks'] = $remark;
|
||||
$insertId = Db::name('user')->insertGetId($user_data);
|
||||
if($insertId){
|
||||
// 写入管理员日志
|
||||
insertAgentLog('添加会员','添加会员:| ID: '.$insertId.' | 账号: '.$username);
|
||||
Db::name('user')->where(array('id' => $insertId))->update(array('agent_parent_id_path' => $agentParent['agent_parent_id_path'] . ',' . $insertId));
|
||||
// 生成U地址 总代为 现金线 波场类的支付渠道
|
||||
$topAgentId = explode(',',$user_info['agent_parent_id_path'])[0];
|
||||
$topAgent = Db::name('user')->where('id',$topAgentId)->find();
|
||||
if($topAgent['agent_type'] == 1 && $topAgent['pay_channel'] == "USDT"){
|
||||
$Usdt = new Usdt();
|
||||
$result = $Usdt->newUserWallet();
|
||||
if(isset($result['code']) && $result['code'] == 0){
|
||||
$walletData = [
|
||||
'user_id' => $insertId,
|
||||
'address' => $result['wallet']['address'],
|
||||
'parent_id' => $result['wallet']['parent_id'],
|
||||
'status' => $result['wallet']['status'],
|
||||
'tid' => $result['wallet']['tid'],
|
||||
'type' => $result['wallet']['type'],
|
||||
'create_time' => time(),
|
||||
'update_time' => time(),
|
||||
];
|
||||
Db::name('user_wallet')->insert($walletData);
|
||||
}
|
||||
}
|
||||
die(json_encode(['code'=>1,'msg'=>$lang['added_successfully']]));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['add_failed']]));
|
||||
}
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['operation_error']]));
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑会员页面
|
||||
public function edit(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
|
||||
$user_info = Session::get('user_info');
|
||||
if($user_info['account_type'] == 2 || $user_info['account_type'] == 3){
|
||||
return $lang['illegal_request'];
|
||||
}
|
||||
// 接收需要修改的会员ID
|
||||
$user_id = Request::instance()->get('user_id');
|
||||
$user = Db::name('user')->where('id',$user_id)->find();
|
||||
$price_dice_arr = result_to_array($user['price_dice']);
|
||||
foreach ($price_dice_arr as $key => $value){
|
||||
$user['dice_price_'.$key] = $value;
|
||||
}
|
||||
/*
|
||||
$price_roulette_arr = result_to_array($user['price_roulette']);
|
||||
foreach ($price_roulette_arr as $key => $value){
|
||||
$user['roulette_price_'.$key] = $value;
|
||||
}
|
||||
*/
|
||||
// 格式化数据
|
||||
$user['agent_commission'] = round($user['agent_commission'],2);
|
||||
$user['agent_commission_dt'] = round($user['agent_commission_dt'],2);
|
||||
$user['agent_commission_nn'] = round($user['agent_commission_nn'],2);
|
||||
$user['agent_commission_tc'] = round($user['agent_commission_tc'],2);
|
||||
$user['agent_commission_tc_banker'] = round($user['agent_commission_tc_banker'],2);
|
||||
$user['win_limit'] = round($user['win_limit'],2);
|
||||
|
||||
// 所属代理信息
|
||||
$agent_parent = Db::name('user')->where('id',$user['agent_parent_id'])->find();
|
||||
|
||||
// 总代性质
|
||||
$topAgentId = explode(',',$user_info['agent_parent_id_path'])[0];
|
||||
$topAgent = Db::name('user')->where('id',$topAgentId)->find();
|
||||
$user['agent_type'] = $topAgent['agent_type'];
|
||||
|
||||
$manager_list = [];
|
||||
if($agent_parent['bet_type'] == 2){
|
||||
if($agent_parent['agent_parent_id'] == 0){
|
||||
$manager_list = Db::name('manager')->where('parent_agent_id',$agent_parent['id'])->where('status',1)->field(['id','nickname'])->select();
|
||||
}else{
|
||||
$whereManager = explode(',',$agent_parent['agent_manager_id_list']);
|
||||
$manager_list = Db::name('manager')->whereIn('id',$whereManager)->where('status',1)->field(['id','nickname'])->select();
|
||||
}
|
||||
}
|
||||
|
||||
//渲染参数和模板
|
||||
$this->assign('user',$user);
|
||||
$this->assign('user_info',$user_info);
|
||||
$this->assign('manager_list',$manager_list);
|
||||
$this->assign('agent_parent',$agent_parent);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 处理编辑会员
|
||||
public function do_edit(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::name('user')->where('id',$user_info['id'])->find();
|
||||
$user_info['account_type'] = $account_type;
|
||||
if($user_info['account_type'] == 2 || $user_info['account_type'] == 3){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['illegal_request']]));
|
||||
}
|
||||
if(Request::instance()->post()){
|
||||
// 获取管理员信息
|
||||
$user_info = Session::get('user_info');
|
||||
|
||||
// 接收参数
|
||||
$parent_id = Request::instance()->post('parent_id');
|
||||
$user_id = Request::instance()->post('user_id');
|
||||
$nickname = Request::instance()->post('nickname');
|
||||
$mobile = trim(Request::instance()->post('mobile'));
|
||||
// 编辑会员时不改变bet_type,保留原值
|
||||
//$bet_type = Request::instance()->post('bet_type');
|
||||
$agent_commission = round(Request::instance()->post('agent_commission'),2);
|
||||
$agent_commission_dt = round(Request::instance()->post('agent_commission_dt'),2);
|
||||
$agent_commission_nn = round(Request::instance()->post('agent_commission_nn'),2);
|
||||
$agent_commission_tc = round(Request::instance()->post('agent_commission_tc'),2);
|
||||
$agent_commission_tc_banker = round(Request::instance()->post('agent_commission_tc_banker'),2);
|
||||
$win_limit = round(Request::instance()->post('win_limit'),2);
|
||||
$limit_low = round(Request::instance()->post('limit_low'),2);
|
||||
$limit_high = round(Request::instance()->post('limit_high'),2);
|
||||
$limit_low_tie = round(Request::instance()->post('limit_low_tie'),2);
|
||||
$limit_high_tie = round(Request::instance()->post('limit_high_tie'),2);
|
||||
$limit_low_pair = round(Request::instance()->post('limit_low_pair'),2);
|
||||
$limit_high_pair = round(Request::instance()->post('limit_high_pair'),2);
|
||||
$limit_low_nn = round(Request::instance()->post('limit_low_nn'),2);
|
||||
$limit_high_nn = round(Request::instance()->post('limit_high_nn'),2);
|
||||
$agent_ximalv = round(Request::instance()->post('agent_ximalv'),2);
|
||||
$agent_ximalv_dt = round(Request::instance()->post('agent_ximalv_dt'),2);
|
||||
$agent_ximalv_nn = round(Request::instance()->post('agent_ximalv_nn'),2);
|
||||
$agent_ximalv_tc = round(Request::instance()->post('agent_ximalv_tc'),2);
|
||||
|
||||
$rebate_rate = Request::instance()->post('rebate_rate');
|
||||
$manager_id = Request::instance()->post('manager_id');
|
||||
$remark = Request::instance()->post('remark');
|
||||
|
||||
// 验证数据
|
||||
if($parent_id <= 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['parent_error']]));
|
||||
}
|
||||
$agentParent = Db::name('user')->where('id',$parent_id)->find();
|
||||
if(!$agentParent || $agentParent['agent'] == 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['parent_error']]));
|
||||
}
|
||||
if(!$nickname){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['empty_nickname']]));
|
||||
}
|
||||
/*
|
||||
if(!$mobile){
|
||||
die(json_encode(['code'=>0,'msg'=>'请填写手机!']));
|
||||
}
|
||||
*/
|
||||
if($agent_commission >= 10){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['agent_baccarat_cannot_exceed_10']]));
|
||||
}
|
||||
if($agent_commission_dt >= 10){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['agent_dt_cannot_exceed_10']]));
|
||||
}
|
||||
if($agent_commission_nn >= 10){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['agent_cow_cannot_exceed_10']]));
|
||||
}
|
||||
if($agent_commission_tc >= 10){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['agent_tc_cannot_exceed_10']]));
|
||||
}
|
||||
if($agent_commission_tc_banker >= 10){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['agent_commission_tc_cannot_exceed_10']]));
|
||||
}
|
||||
if($limit_low < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_limit_0']]));
|
||||
}
|
||||
if($limit_high < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['max_limit_0']]));
|
||||
}
|
||||
if($limit_low > $limit_high && $limit_low > 0 && $limit_high > 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_limit_bigger_than_max_limit']]));
|
||||
}
|
||||
if($limit_low_tie < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_tie_limit_0']]));
|
||||
}
|
||||
if($limit_high_tie < 0){
|
||||
die(json_encode(['code'=>0,'msg'=> $lang['max_tie_limit_0']]));
|
||||
}
|
||||
if($limit_low_tie > $limit_high_tie && $limit_low_tie > 0 && $limit_high_tie > 0){
|
||||
die(json_encode(['code'=>0,'msg'=> $lang['min_tie_limit_bigger_than_max_tie_limit']]));
|
||||
}
|
||||
if($limit_low_pair < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_pair_limit_0']]));
|
||||
}
|
||||
if($limit_high_pair < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['max_pair_limit_0']]));
|
||||
}
|
||||
if($limit_low_pair > $limit_high_pair && $limit_low_pair > 0 && $limit_high_pair > 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_pair_limit_bigger_than_max_tie_limit']]));
|
||||
}
|
||||
if($limit_low < $agentParent['limit_low'] || $limit_low > $agentParent['limit_high'] || $limit_high < $agentParent['limit_low'] || $limit_high > $agentParent['limit_high']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['limit_cannot_bigger'].' '.$agentParent['limit_low'].'-'.$agentParent['limit_high']]));
|
||||
}
|
||||
if($limit_low_tie < $agentParent['limit_low_tie'] || $limit_low_tie > $agentParent['limit_high_tie'] || $limit_high_tie < $agentParent['limit_low_tie'] || $limit_high_tie > $agentParent['limit_high_tie']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['tie_limit_cannot_bigger'].' '.$agentParent['limit_low_tie'].'-'.$agentParent['limit_high_tie']]));
|
||||
}
|
||||
if($limit_low_pair < $agentParent['limit_low_pair'] || $limit_low_pair > $agentParent['limit_high_pair'] || $limit_high_pair < $agentParent['limit_low_pair'] || $limit_high_pair > $agentParent['limit_high_pair']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['pair_limit_cannot_bigger'].' '.$agentParent['limit_low_pair'].'-'.$agentParent['limit_high_pair']]));
|
||||
}
|
||||
if($limit_low_nn < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_nn_limit_0']]));
|
||||
}
|
||||
if($limit_high_nn < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['max_nn_limit_0']]));
|
||||
}
|
||||
if($limit_low_nn > $limit_high_nn && $limit_low_nn > 0 && $limit_high_nn > 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['min_nn_limit_bigger_than_max']]));
|
||||
}
|
||||
if($limit_low_nn > 0 && $limit_high_nn > 0 && $agentParent['limit_low_nn'] > 0 && $agentParent['limit_high_nn'] > 0){
|
||||
if($limit_low_nn < $agentParent['limit_low_nn'] || $limit_low_nn > $agentParent['limit_high_nn'] || $limit_high_nn < $agentParent['limit_low_nn'] || $limit_high_nn > $agentParent['limit_high_nn']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['nn_limit_cannot_bigger'].' '.$agentParent['limit_low_nn'].'-'.$agentParent['limit_high_nn']]));
|
||||
}
|
||||
}
|
||||
|
||||
if($agent_ximalv > $agentParent['agent_ximalv']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['baccarat_cannot_bigger_agent'].$agentParent['agent_ximalv'].'!']));
|
||||
}
|
||||
if($agent_ximalv_dt > $agentParent['agent_ximalv_dt']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['dt_cannot_bigger_agent'].$agentParent['agent_ximalv_dt'].'!']));
|
||||
}
|
||||
if($agent_ximalv_nn > $agentParent['agent_ximalv_nn']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['cow_cannot_bigger_agent'].$agentParent['agent_ximalv_nn'].'!']));
|
||||
}
|
||||
if($agent_ximalv_tc > $agentParent['agent_ximalv_tc']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['tc_cannot_bigger_agent'].$agentParent['agent_ximalv_tc'].'!']));
|
||||
}
|
||||
if($rebate_rate && $rebate_rate > $agentParent['rebate_rate']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['rebate_cannot_bigger_agent'].' '.$agentParent['rebate_rate'].'!']));
|
||||
}
|
||||
if($agentParent['bet_type'] == 2){
|
||||
if(!$manager_id){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['select_manager']]));
|
||||
}
|
||||
}
|
||||
|
||||
// 拼装数据创建会员
|
||||
$user_data = array();
|
||||
$user_data['nickname'] = $nickname;
|
||||
$user_data['mobile'] = $mobile;
|
||||
$user_data['agent_commission'] = $agent_commission;
|
||||
$user_data['agent_commission_dt'] = $agent_commission_dt;
|
||||
$user_data['agent_commission_nn'] = $agent_commission_nn;
|
||||
$user_data['agent_commission_tc'] = $agent_commission_tc;
|
||||
$user_data['agent_commission_tc_banker'] = $agent_commission_tc_banker;
|
||||
$user_data['win_limit'] = $win_limit;
|
||||
$user_data['limit_low'] = $limit_low;
|
||||
$user_data['limit_high'] = $limit_high;
|
||||
$user_data['limit_low_tie'] = $limit_low_tie;
|
||||
$user_data['limit_high_tie'] = $limit_high_tie;
|
||||
$user_data['limit_low_pair'] = $limit_low_pair;
|
||||
$user_data['limit_high_pair'] = $limit_high_pair;
|
||||
$user_data['limit_low_nn'] = $limit_low_nn;
|
||||
$user_data['limit_high_nn'] = $limit_high_nn;
|
||||
$user_data['agent_ximalv'] = $agent_ximalv;
|
||||
$user_data['agent_ximalv_dt'] = $agent_ximalv_dt;
|
||||
$user_data['agent_ximalv_nn'] = $agent_ximalv_nn;
|
||||
$user_data['agent_ximalv_tc'] = $agent_ximalv_tc;
|
||||
$user_data['manager_id'] = $manager_id;
|
||||
if ($rebate_rate){
|
||||
$user_data['rebate_rate'] = $rebate_rate;
|
||||
}
|
||||
$user_data['update_time'] = time();
|
||||
$user_data['remarks'] = $remark;
|
||||
$result = Db::name('user')->where('id',$user_id)->update($user_data);
|
||||
if($result){
|
||||
// 写入管理员日志
|
||||
$user = Db::name('user')->where('id',$user_id)->find();
|
||||
insertAgentLog('编辑会员','编辑会员:| ID: '.$user['id'].' | 账号: '.$user['username']);
|
||||
}
|
||||
die(json_encode(['code'=>1,'msg'=>$lang['edit_successfully']]));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['operation_error']]));
|
||||
}
|
||||
}
|
||||
// 编辑会员页面
|
||||
public function edit_agent(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
|
||||
$user_info = Session::get('user_info');
|
||||
if($user_info['account_type'] == 2 || $user_info['account_type'] == 3){
|
||||
return $lang['illegal_request'];
|
||||
}
|
||||
if($user_info['agent_parent_id'] == 0){
|
||||
$under_agent_list = Db::name('user')->where('agent_parent_id_path','like',$user_info['id'].',%')->whereOr('id',$user_info['id'])->where('agent',1)->order('id asc')->select();
|
||||
}else{
|
||||
$under_agent_list = Db::name('user')->where('agent_parent_id_path','like','%,'.$user_info['id'].',%')->where('agent',1)->order('id asc')->select();
|
||||
}
|
||||
|
||||
// 接收需要修改的会员ID
|
||||
$user_id = Request::instance()->get('user_id');
|
||||
$user = Db::name('user')->where('id',$user_id)->find();
|
||||
// 格式化数据
|
||||
|
||||
// 所属代理信息
|
||||
$agent_parent = Db::name('user')->where('id',$user['agent_parent_id'])->find();
|
||||
|
||||
//渲染参数和模板
|
||||
$this->assign('user',$user);
|
||||
$this->assign('user_info',$user_info);
|
||||
$this->assign('under_agent_list',$under_agent_list);
|
||||
$this->assign('agent_parent',$agent_parent);
|
||||
return $this->fetch();
|
||||
}
|
||||
// 处理编辑会员
|
||||
public function do_edit_agent(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::name('user')->where('id',$user_info['id'])->find();
|
||||
$user_info['account_type'] = $account_type;
|
||||
if($user_info['account_type'] == 2 || $user_info['account_type'] == 3){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['illegal_request']]));
|
||||
}
|
||||
if(Request::instance()->post()){
|
||||
// 获取管理员信息
|
||||
$user_info = Session::get('user_info');
|
||||
|
||||
// 接收参数
|
||||
$user_id = Request::instance()->post('user_id');
|
||||
$new_agent_id = Request::instance()->post('new_agent_id');
|
||||
$update_user_info = Db::name('user')->where('id',$user_id)->find();
|
||||
// 验证数据
|
||||
if($new_agent_id == 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['choose_the_new_agent']]));
|
||||
}
|
||||
$user_bet = Db::name('bet')->where('user_id',$user_id)->select();
|
||||
if($user_bet){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['already_bet']]));
|
||||
}
|
||||
if($update_user_info['money'] > 0 ){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['already_recharge']]));
|
||||
}
|
||||
$new_agent_info = Db::name('user')->where('id',$new_agent_id)->where('agent',1)->find();
|
||||
if(!$new_agent_info){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['new_agent_error']]));
|
||||
}
|
||||
$wt_agent = Db::connect('DB2')->name('table')->where(array('status' => 1))->order('id asc')->limit(1)->value('wt_agent');
|
||||
if($wt_agent != $user_info['username']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['cannot_do']]));
|
||||
}
|
||||
|
||||
// 拼装数据创建会员
|
||||
$user_data = array();
|
||||
$user_data['agent_parent_id'] = $new_agent_info['id'];
|
||||
$user_data['agent_parent_username'] = $new_agent_info['username'];
|
||||
$user_data['agent_parent_nickname'] = $new_agent_info['nickname'];
|
||||
$user_data['agent_parent_id_path'] = $new_agent_info['agent_parent_id_path'].','.$user_id;
|
||||
$user_data['update_time'] = time();
|
||||
$result = Db::name('user')->where('id',$user_id)->update($user_data);
|
||||
if($result){
|
||||
// 写入管理员日志
|
||||
$user = Db::name('user')->where('id',$user_id)->find();
|
||||
insertAgentLog('编辑会员','编辑会员:| ID: '.$user['id'].' | 账号: '.$user['username']);
|
||||
}
|
||||
die(json_encode(['code'=>1,'msg'=>$lang['edit_successfully']]));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['operation_error']]));
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+4161
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,952 @@
|
||||
<?php
|
||||
namespace app\agent\controller;
|
||||
use \think\Controller;
|
||||
use think\Lang;
|
||||
use \think\Session;
|
||||
use \think\Request;
|
||||
use \think\Db;
|
||||
class Settle Extends Common{
|
||||
// 洗码显示表
|
||||
public function xima(){
|
||||
Session::set('allowSubmit',"YES");
|
||||
$user_id = intval(Request::instance()->get('user_id'));
|
||||
if($user_id > 0){
|
||||
// 获取查询代理信息
|
||||
$user_info = Db::name('user')->where('id',$user_id)->find();
|
||||
if(empty($user_info)){
|
||||
die('用户错误');
|
||||
}
|
||||
}else{
|
||||
die('用户错误');
|
||||
}
|
||||
$timeLength = Request::instance()->get('time_length');
|
||||
if(isset($timeLength)){
|
||||
$timeLength = intval(Request::instance()->get('time_length'));
|
||||
}else{
|
||||
$timeLength = 1;
|
||||
}
|
||||
$where = array();
|
||||
if($timeLength == 1 || $timeLength == 2 || $timeLength == 3){
|
||||
if($timeLength == 1 || $timeLength == 2){
|
||||
if($timeLength == 1){
|
||||
//上周时间
|
||||
$weekStart = date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),date("d")-date("w")+1-7,date("Y")));
|
||||
$weekEnd = date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("d")-date("w")+7-7,date("Y")));
|
||||
}elseif($timeLength == 2){
|
||||
//本周时间
|
||||
$weekStart = date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y")));
|
||||
$weekEnd = date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y")));
|
||||
}
|
||||
$startTime = strtotime($weekStart);
|
||||
$endTime = strtotime($weekEnd);
|
||||
$where['create_time'] = array('between',[$startTime,$endTime]);
|
||||
}else{
|
||||
$weekStart = '';
|
||||
$weekEnd = '';
|
||||
}
|
||||
}else{
|
||||
die('请选择结算周期');
|
||||
}
|
||||
$where['is_checkout'] = 0;
|
||||
$where['user_id'] = $user_info['id'];
|
||||
// 洗码总量
|
||||
$user_info['ximaliang'] = Db::name('xima')->where($where)->sum('ximaliang');
|
||||
// 未结码量
|
||||
//$user_info['maliang_unbalanced'] = Db::name('xima')->where($where)->sum('maliang_true');
|
||||
$user_info['maliang_unbalanced'] = Db::name('xima')->where($where)->sum('maliang');
|
||||
// 最近洗码时间
|
||||
if($user_info['last_xima_time'] > 0){
|
||||
$user_info['last_xima_time'] = date('Y-m-d H:i:s',$user_info['last_xima_time']);
|
||||
}else{
|
||||
$user_info['last_xima_time'] = '-';
|
||||
}
|
||||
// 渲染参数和模板
|
||||
$this->assign('time_start',$weekStart);
|
||||
$this->assign('time_end',$weekEnd);
|
||||
$this->assign('time_length',$timeLength);
|
||||
$this->assign('user_info',$user_info);
|
||||
return $this->fetch();
|
||||
}
|
||||
// 处理洗码
|
||||
public function do_xima(){
|
||||
if(Request::instance()->post()){
|
||||
//防止重复提交
|
||||
$allowSubmit = Session::get('allowSubmit');
|
||||
if($allowSubmit == 'YES'){
|
||||
Session::delete('allowSubmit');
|
||||
}else{
|
||||
Session::delete('allowSubmit');
|
||||
return json(array('code' => 0, 'msg' => "请勿重复提交"));
|
||||
}
|
||||
// 登录用户信息
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::name('user')->where('id',$user_info['id'])->find();
|
||||
$user_info['account_type'] = $account_type;
|
||||
|
||||
// 接收洗码用户ID
|
||||
$user_id = Request::instance()->post('user_id');
|
||||
$type_xima = Request::instance()->post('type_xima');
|
||||
$timeLength = Request::instance()->post('time_length');
|
||||
if($timeLength != 1 && $timeLength != 2 && $timeLength != 3){
|
||||
return json(array('code'=>0,'msg'=>'洗码出错'));
|
||||
}
|
||||
$startDate = Request::instance()->post('time_start');
|
||||
$endDate = Request::instance()->post('time_end');
|
||||
if($user_id > 0){
|
||||
// 查询要洗码的用户信息
|
||||
$user = Db::name('user')->where('id',$user_id)->find();
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'洗码用户错误']));
|
||||
}
|
||||
if(!in_array($type_xima,[1,2])){
|
||||
die(json_encode(['code'=>0,'msg'=>'请选择洗码方式']));
|
||||
}
|
||||
|
||||
// 判断是不是直属
|
||||
if($user['agent_parent_id'] != $user_info['id']){
|
||||
die(json_encode(['code'=>0,'msg'=>'账号'.$user['username'].'不是您的直属下级,无法洗码']));
|
||||
}
|
||||
|
||||
$ximaWhere = array();
|
||||
if($timeLength == 1 || $timeLength == 2){
|
||||
$startTime = strtotime($startDate);
|
||||
$endTime = strtotime($endDate);
|
||||
if($startTime > 0 && $endTime > 0){
|
||||
$ximaWhere['create_time'] = array('between',[$startTime,$endTime]);
|
||||
}else{
|
||||
return json(array('code'=>0,'msg'=>'请正确选择洗码时间'));
|
||||
}
|
||||
}
|
||||
$ximaWhere['user_id'] = $user['id'];
|
||||
$ximaWhere['is_checkout'] = 0;
|
||||
// 未结码量
|
||||
$ximaliang_unbalanced = Db::name('xima')->where($ximaWhere)->sum('ximaliang');
|
||||
$maliang_unbalanced = Db::name('xima')->where($ximaWhere)->sum('maliang');
|
||||
// 验证码量
|
||||
if($maliang_unbalanced <= 0){
|
||||
die(json_encode(['code'=>0,'msg'=>'未结码量必须要大于0!']));
|
||||
}
|
||||
|
||||
// 处理洗码(更新洗码时间)
|
||||
if($type_xima == 1){
|
||||
$moneycontrol = $user_info['money'] - $maliang_unbalanced;
|
||||
if($moneycontrol < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>'余额不足!']));
|
||||
}
|
||||
Db::name('user')->where(['id'=>$user_info['id']])->update(['money'=>$moneycontrol]);
|
||||
$money = $user['money'] + $maliang_unbalanced;
|
||||
$result = Db::name('user')->where(['id'=>$user['id']])->update(['money'=>$money,'last_xima_time'=>time()]);
|
||||
}else{
|
||||
$result = Db::name('user')->where(['id'=>$user['id']])->update(['last_xima_time'=>time()]);
|
||||
}
|
||||
|
||||
if(!$result){
|
||||
die(json_encode(['code'=>0,'msg'=>'洗码失败!']));
|
||||
}
|
||||
|
||||
// 更新洗码表状态
|
||||
Db::name('xima')->where($ximaWhere)->update(['is_checkout'=>1,'checkout_time'=>time()]);
|
||||
// 处理洗码
|
||||
$dataXima = array();
|
||||
$dataXima['user_id'] = $user['id'];
|
||||
$dataXima['username'] = $user['username'];
|
||||
$dataXima['admin_or_agent'] = 2;
|
||||
$dataXima['connection_id'] = $user_info['id'];
|
||||
$dataXima['connection_username'] = $user_info['username'];
|
||||
$dataXima['ximaliang'] = $ximaliang_unbalanced;
|
||||
$dataXima['maliang'] = $maliang_unbalanced;
|
||||
if($user['type_xima'] == 1){
|
||||
$dataXima['agent_ximalv'] = $user['agent_ximalv'].'/'.$user['agent_ximalv_dt'].'/'.$user['agent_ximalv_nn'];
|
||||
}elseif($user['type_xima'] == 2){
|
||||
$dataXima['agent_ximalv'] = $user['agent_ximalv_single'].'/'.$user['agent_ximalv_dt_single'].'/'.$user['agent_ximalv_nn_single'];
|
||||
}else{
|
||||
$dataXima['agent_ximalv'] = '0/0/0';
|
||||
}
|
||||
$dataXima['create_time'] = time();
|
||||
if($type_xima == 1){
|
||||
$dataXima['old_money'] = $user['money'];
|
||||
$dataXima['new_money'] = $user['money'] + $maliang_unbalanced;
|
||||
$dataXima['connection_old_money'] = $user_info['money'];
|
||||
$dataXima['connection_new_money'] = $user_info['money'] - $maliang_unbalanced;
|
||||
}else{
|
||||
$dataXima['old_money'] = $user['money'];
|
||||
$dataXima['new_money'] = $user['money'];
|
||||
$dataXima['connection_old_money'] = $user_info['money'];
|
||||
$dataXima['connection_new_money'] = $user_info['money'];
|
||||
}
|
||||
$dataXima['type'] = $type_xima;
|
||||
Db::name('xima_log')->insert($dataXima);
|
||||
|
||||
|
||||
if($type_xima == 1){
|
||||
// 处理下分 下级
|
||||
$dataRecharge = array();
|
||||
$dataRecharge['type'] = 2;
|
||||
$dataRecharge['amount'] = $maliang_unbalanced;
|
||||
$dataRecharge['mode'] = 1;
|
||||
$dataRecharge['agent_or_admin'] = 2;
|
||||
$dataRecharge['controller_id'] = $user_info['id'];
|
||||
$dataRecharge['controller_username'] = $user_info['username'];
|
||||
$dataRecharge['controller_nickname'] = $user_info['nickname'];
|
||||
$dataRecharge['controller_type'] = '代理系统操作';
|
||||
$dataRecharge['user_id'] = $user['id'];
|
||||
$dataRecharge['user_type'] = $user['agent'];
|
||||
$dataRecharge['user_agent_level'] = $user['agent_level'];
|
||||
$dataRecharge['username_for'] = $user['username'];
|
||||
$dataRecharge['nickname_for'] = $user['nickname'];
|
||||
$dataRecharge['user_parent_id'] = $user['agent_parent_id'];
|
||||
$dataRecharge['create_time'] = time();
|
||||
$dataRecharge['old_money'] = $user['money'];
|
||||
$dataRecharge['new_money'] = $user['money'] + $maliang_unbalanced;
|
||||
$dataRecharge['controller_old_money'] = $user_info['money'];
|
||||
$dataRecharge['controller_new_money'] = $user_info['money'] - $maliang_unbalanced;
|
||||
$dataRecharge['controller_system'] = 1;
|
||||
if($timeLength == 3){
|
||||
$dataRecharge['remake'] = '洗码上分,洗码时间范围为全部洗码';
|
||||
}else{
|
||||
$dataRecharge['remake'] = '洗码上分,洗码时间范围为'.$startDate.'至'.$endDate;
|
||||
}
|
||||
Db::name('recharge')->insert($dataRecharge);
|
||||
|
||||
// 处理下分(上级)
|
||||
$dataRecharge = array();
|
||||
$dataRecharge['type'] = 2;
|
||||
$dataRecharge['amount'] = $maliang_unbalanced;
|
||||
$dataRecharge['mode'] = 2;
|
||||
$dataRecharge['agent_or_admin'] = 2;
|
||||
$dataRecharge['controller_id'] = $user_info['id'];
|
||||
$dataRecharge['controller_username'] = $user_info['username'];
|
||||
$dataRecharge['controller_nickname'] = $user_info['nickname'];
|
||||
$dataRecharge['controller_type'] = '代理系统操作';
|
||||
$dataRecharge['user_id'] = $user_info['id'];
|
||||
$dataRecharge['user_type'] = $user_info['agent'];
|
||||
$dataRecharge['user_agent_level'] = $user_info['agent_level'];
|
||||
$dataRecharge['username_for'] = $user_info['username'];
|
||||
$dataRecharge['nickname_for'] = $user_info['nickname'];
|
||||
$dataRecharge['user_parent_id'] = $user_info['agent_parent_id'];
|
||||
$dataRecharge['create_time'] = time();
|
||||
$dataRecharge['old_money'] = $user_info['money'];
|
||||
$dataRecharge['new_money'] = $user_info['money'] - $maliang_unbalanced;
|
||||
$dataRecharge['controller_old_money'] = $user_info['money'];
|
||||
$dataRecharge['controller_new_money'] = $user_info['money'] - $maliang_unbalanced;
|
||||
$dataRecharge['controller_system'] = 1;
|
||||
$dataRecharge['remake'] = '下级洗码结算(上分),上级余额相应处理';
|
||||
Db::name('recharge')->insert($dataRecharge);
|
||||
}
|
||||
die(json_encode(['code'=>1,'msg'=>'洗码成功']));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'操作错误!']));
|
||||
}
|
||||
}
|
||||
|
||||
// 结算显示表
|
||||
public function cs(){
|
||||
Session::set('allowSubmit',"YES");
|
||||
// 接收洗码用户ID
|
||||
$user_id = Request::instance()->get('user_id');
|
||||
if($user_id > 0){
|
||||
$user_info = Db::name('user')->where('id',$user_id)->find();
|
||||
if(empty($user_info)){
|
||||
die('用户错误');
|
||||
}
|
||||
}else{
|
||||
die('用户错误!');
|
||||
}
|
||||
$startDate = Request::instance()->get('startDate');
|
||||
$endDate = Request::instance()->get('endDate');
|
||||
$where = array();
|
||||
if(isset($startDate) && isset($endDate)){
|
||||
$startTime = strtotime($startDate);
|
||||
$endTime = strtotime($endDate);
|
||||
$where['create_time'] = array('between',[$startTime,$endTime]);
|
||||
$this->assign('startDate',$startDate);
|
||||
$this->assign('endDate',$endDate);
|
||||
}
|
||||
$where['user_id'] = $user_info['id'];
|
||||
$where['is_checkout'] = 0;
|
||||
// 总赢
|
||||
$user_info['win_total'] = Db::name('cs')->where($where)->sum('win_total');
|
||||
// 未结占成
|
||||
$user_info['cs_unbalanced'] = Db::name('cs')->where($where)->sum('share_amount');
|
||||
// 分担码量
|
||||
$user_info['share_maliang'] = Db::name('cs')->where($where)->sum('share_maliang');
|
||||
// 最近结算时间
|
||||
if($user_info['last_cs_time'] > 0){
|
||||
$user_info['last_cs_time'] = date('Y-m-d H:i:s',$user_info['last_cs_time']);
|
||||
}else{
|
||||
$user_info['last_cs_time'] = '-';
|
||||
}
|
||||
// 渲染参数和模板
|
||||
$this->assign('user_info',$user_info);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 处理结算
|
||||
public function do_cs(){
|
||||
if(Request::instance()->post()){
|
||||
//防止重复提交
|
||||
$allowSubmit = Session::get('allowSubmit');
|
||||
if($allowSubmit == 'YES'){
|
||||
Session::delete('allowSubmit');
|
||||
}else{
|
||||
Session::delete('allowSubmit');
|
||||
return json(array('code' => 0, 'msg' => "请勿重复提交"));
|
||||
}
|
||||
// 登录用户信息
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::name('user')->where('id',$user_info['id'])->find();
|
||||
$user_info['account_type'] = $account_type;
|
||||
// 接收洗码用户ID
|
||||
$user_id = Request::instance()->post('user_id');
|
||||
$type_cs = Request::instance()->post('type_cs');
|
||||
if($user_id > 0){
|
||||
// 查询要洗码的用户信息
|
||||
$user = Db::name('user')->where('id',$user_id)->find();
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'结算用户错误!']));
|
||||
}
|
||||
if(!in_array($type_cs,[1,2])){
|
||||
die(json_encode(['code'=>0,'msg'=>'请选择结算方式!']));
|
||||
}
|
||||
// 判断是不是直属
|
||||
if($user['agent_parent_id'] != $user_info['id']){
|
||||
die(json_encode(['code'=>0,'msg'=>'账号'.$user['username'].'不是您的直属下级,无法结算']));
|
||||
}
|
||||
$startDate = Request::instance()->post('startDate');
|
||||
$endDate = Request::instance()->post('endDate');
|
||||
$where = array();
|
||||
if(isset($startDate) && isset($endDate)){
|
||||
$startTime = strtotime($startDate);
|
||||
$endTime = strtotime($endDate);
|
||||
if($startTime > 0 && $endTime > 0){
|
||||
$where['create_time'] = array('between',[$startTime,$endTime]);
|
||||
}
|
||||
}
|
||||
$where['user_id'] = $user['id'];
|
||||
$where['is_checkout'] = 0;
|
||||
// 总赢
|
||||
$win_total = Db::name('cs')->where($where)->sum('win_total');
|
||||
$cs_unbalanced = Db::name('cs')->where($where)->sum('share_amount');
|
||||
$share_maliang = Db::name('cs')->where($where)->sum('share_maliang');
|
||||
// 验证码量
|
||||
if($cs_unbalanced == 0 && $share_maliang == 0){
|
||||
die(json_encode(['code'=>0,'msg'=>'结算占成收益不能为0']));
|
||||
}
|
||||
// 处理结算(更新结算时间)
|
||||
if($type_cs == 1){
|
||||
$moneycontrol = $user_info['money'] - $cs_unbalanced + $share_maliang;
|
||||
if($moneycontrol < 0){
|
||||
die(json_encode(['code'=>0,'msg'=>'余额不足!']));
|
||||
}
|
||||
Db::name('user')->where(['id'=>$user_info['id']])->update(['money'=>$moneycontrol]);
|
||||
$money = $user['money'] + $cs_unbalanced - $share_maliang;
|
||||
$result = Db::name('user')->where(['id'=>$user['id']])->update(['money'=>$money,'last_cs_time'=>time()]);
|
||||
}else{
|
||||
$result = Db::name('user')->where(['id'=>$user['id']])->update(['last_cs_time'=>time()]);
|
||||
}
|
||||
if(!$result){
|
||||
die(json_encode(['code'=>0,'msg'=>'结算失败!']));
|
||||
}
|
||||
// 更新占成状态
|
||||
Db::name('cs')->where($where)->update(['is_checkout'=>1,'checkout_time'=>time()]);
|
||||
// 处理结算
|
||||
$dataCs = array();
|
||||
$dataCs['user_id'] = $user['id'];
|
||||
$dataCs['username'] = $user['username'];
|
||||
$dataCs['admin_or_agent'] = 2;
|
||||
$dataCs['connection_id'] = $user_info['id'];
|
||||
$dataCs['connection_username'] = $user_info['username'];
|
||||
$dataCs['share_amount'] = $cs_unbalanced;
|
||||
$dataCs['share_maliang'] = $share_maliang;
|
||||
$dataCs['agent_cs'] = $user_info['agent_cs'];
|
||||
$dataCs['create_time'] = time();
|
||||
if($type_cs == 1){
|
||||
$dataCs['old_money'] = $user['money'];
|
||||
$dataCs['new_money'] = $user['money'] + $cs_unbalanced - $share_maliang;
|
||||
$dataCs['connection_old_money'] = $user_info['money'];
|
||||
$dataCs['connection_new_money'] = $user_info['money'] - $cs_unbalanced + $share_maliang;
|
||||
}else{
|
||||
$dataCs['old_money'] = $user['money'];
|
||||
$dataCs['new_money'] = $user['money'];
|
||||
$dataCs['connection_old_money'] = $user_info['money'];
|
||||
$dataCs['connection_new_money'] = $user_info['money'];
|
||||
}
|
||||
$dataCs['type'] = $type_cs;
|
||||
Db::name('cs_log')->insert($dataCs);
|
||||
|
||||
// 确定是上分还是下分
|
||||
$scoreAmount = 0;
|
||||
if($cs_unbalanced > 0){
|
||||
$mode = 1;
|
||||
$scoreAmount = $cs_unbalanced - $share_maliang;
|
||||
}elseif($cs_unbalanced < 0){
|
||||
$mode = 2;
|
||||
$scoreAmount = to_number($cs_unbalanced - $share_maliang);
|
||||
}
|
||||
if($type_cs == 1){
|
||||
// 处理上分(下级)
|
||||
$dataRecharge = array();
|
||||
$dataRecharge['type'] = 3;
|
||||
$dataRecharge['amount'] = $scoreAmount;
|
||||
$dataRecharge['mode'] = $mode;
|
||||
$dataRecharge['agent_or_admin'] = 2;
|
||||
$dataRecharge['controller_id'] = $user_info['id'];
|
||||
$dataRecharge['controller_username'] = $user_info['username'];
|
||||
$dataRecharge['controller_nickname'] = $user_info['nickname'];
|
||||
$dataRecharge['controller_type'] = '代理系统操作';
|
||||
$dataRecharge['user_id'] = $user['id'];
|
||||
$dataRecharge['user_type'] = $user['agent'];
|
||||
$dataRecharge['user_agent_level'] = $user['agent_level'];
|
||||
$dataRecharge['username_for'] = $user['username'];
|
||||
$dataRecharge['nickname_for'] = $user['nickname'];
|
||||
$dataRecharge['user_parent_id'] = $user['agent_parent_id'];
|
||||
$dataRecharge['create_time'] = time();
|
||||
$dataRecharge['old_money'] = $user['money'];
|
||||
$dataRecharge['new_money'] = $user['money'] + $cs_unbalanced - $share_maliang;
|
||||
$dataRecharge['controller_old_money'] = $user_info['money'];
|
||||
$dataRecharge['controller_new_money'] = $user_info['money'] - $cs_unbalanced + $share_maliang;
|
||||
$dataRecharge['controller_system'] = 1;
|
||||
if(isset($startDate) && isset($endDate)){
|
||||
$dataRecharge['remake'] = '占股结算上分,结算时间范围为全部结算';
|
||||
}else{
|
||||
$dataRecharge['remake'] = '占股结算上分,结算时间范围为'.$startDate.'至'.$endDate;
|
||||
}
|
||||
Db::name('recharge')->insert($dataRecharge);
|
||||
|
||||
// 处理下分(上级级)
|
||||
$dataRecharge = array();
|
||||
$dataRecharge['type'] = 3;
|
||||
$dataRecharge['amount'] = $scoreAmount;
|
||||
$dataRecharge['mode'] = $mode == 1 ? 2 : 1;
|
||||
$dataRecharge['agent_or_admin'] = 2;
|
||||
$dataRecharge['controller_id'] = $user_info['id'];
|
||||
$dataRecharge['controller_username'] = $user_info['username'];
|
||||
$dataRecharge['controller_nickname'] = $user_info['nickname'];
|
||||
$dataRecharge['controller_type'] = '代理系统操作';
|
||||
$dataRecharge['user_id'] = $user_info['id'];
|
||||
$dataRecharge['user_type'] = $user_info['agent'];
|
||||
$dataRecharge['user_agent_level'] = $user_info['agent_level'];
|
||||
$dataRecharge['username_for'] = $user_info['username'];
|
||||
$dataRecharge['nickname_for'] = $user_info['nickname'];
|
||||
$dataRecharge['user_parent_id'] = $user_info['agent_parent_id'];
|
||||
$dataRecharge['create_time'] = time();
|
||||
$dataRecharge['old_money'] = $user_info['money'];
|
||||
$dataRecharge['new_money'] = $user_info['money'] - $cs_unbalanced + $share_maliang;
|
||||
$dataRecharge['controller_old_money'] = $user_info['money'];
|
||||
$dataRecharge['controller_new_money'] = $user_info['money'] - $cs_unbalanced + $share_maliang;
|
||||
$dataRecharge['controller_system'] = 1;
|
||||
$dataRecharge['remake'] = '下级洗码结算(上下分),上级余额相应处理';
|
||||
Db::name('recharge')->insert($dataRecharge);
|
||||
}
|
||||
die(json_encode(['code'=>1,'msg'=>'结算成功']));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'操作错误!']));
|
||||
}
|
||||
}
|
||||
|
||||
// 返水显示表
|
||||
public function rebate(){
|
||||
Session::set('allowSubmit',"YES");
|
||||
$user_id = intval(Request::instance()->get('user_id'));
|
||||
if($user_id > 0){
|
||||
// 获取查询代理信息
|
||||
$user_info = Db::name('user')->where('id',$user_id)->find();
|
||||
if(empty($user_info)){
|
||||
die('用户错误');
|
||||
}
|
||||
}else{
|
||||
die('用户错误');
|
||||
}
|
||||
$gameType = intval(Request::instance()->get('game_type'));
|
||||
if(!in_array($gameType,[1,2])){
|
||||
die('结算类型错误');
|
||||
}
|
||||
$timeLength = Request::instance()->get('time_length');
|
||||
if(isset($timeLength)){
|
||||
$timeLength = intval(Request::instance()->get('time_length'));
|
||||
}else{
|
||||
$timeLength = 1;
|
||||
}
|
||||
$where = array();
|
||||
if($timeLength == 1 || $timeLength == 2 || $timeLength == 3){
|
||||
if($timeLength == 1 || $timeLength == 2){
|
||||
if($timeLength == 1){
|
||||
//上周时间
|
||||
$weekStart = date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),date("d")-date("w")+1-7,date("Y")));
|
||||
$weekEnd = date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("d")-date("w")+7-7,date("Y")));
|
||||
}elseif($timeLength == 2){
|
||||
//本周时间
|
||||
$weekStart = date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y")));
|
||||
$weekEnd = date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y")));
|
||||
}
|
||||
$startTime = strtotime($weekStart);
|
||||
$endTime = strtotime($weekEnd);
|
||||
$where['create_time'] = array('between',[$startTime,$endTime]);
|
||||
}else{
|
||||
$weekStart = '';
|
||||
$weekEnd = '';
|
||||
}
|
||||
}else{
|
||||
die('请选择结算周期');
|
||||
}
|
||||
$where['game_type'] = $gameType;
|
||||
$where['is_checkout'] = 0;
|
||||
$where['user_id'] = $user_info['id'];
|
||||
// 下注金额
|
||||
$user_info['amount'] = Db::name('rebate')->where($where)->sum('amount');
|
||||
// 未结返水金额
|
||||
$user_info['rebate_unbalanced'] = Db::name('rebate')->where($where)->sum('rebate_amount_actual');
|
||||
// pre(Db::name('rebate')->getLastSql());
|
||||
// 最近返水时间
|
||||
if($user_info['last_rebate_time'] > 0){
|
||||
$user_info['last_rebate_time'] = date('Y-m-d H:i:s',$user_info['last_rebate_time']);
|
||||
}else{
|
||||
$user_info['last_rebate_time'] = '-';
|
||||
}
|
||||
// 渲染参数和模板
|
||||
$this->assign('time_start',$weekStart);
|
||||
$this->assign('time_end',$weekEnd);
|
||||
$this->assign('time_length',$timeLength);
|
||||
$this->assign('user_info',$user_info);
|
||||
$this->assign('game_type',$gameType);
|
||||
return $this->fetch();
|
||||
}
|
||||
// 处理返水
|
||||
public function do_rebate(){
|
||||
if(Request::instance()->post()){
|
||||
//防止重复提交
|
||||
$allowSubmit = Session::get('allowSubmit');
|
||||
if($allowSubmit == 'YES'){
|
||||
Session::delete('allowSubmit');
|
||||
}else{
|
||||
Session::delete('allowSubmit');
|
||||
return json(array('code' => 0, 'msg' => "请勿重复提交"));
|
||||
}
|
||||
// 登录用户信息
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::name('user')->where('id',$user_info['id'])->find();
|
||||
$user_info['account_type'] = $account_type;
|
||||
|
||||
// 接收洗码用户ID
|
||||
$user_id = Request::instance()->post('user_id');
|
||||
$gameType = intval(Request::instance()->post('game_type'));
|
||||
if(!in_array($gameType,[1,2])){
|
||||
return json(array('code'=>0,'msg'=>'结算类型错误'));
|
||||
}
|
||||
$timeLength = Request::instance()->post('time_length');
|
||||
if($timeLength != 1 && $timeLength != 2 && $timeLength != 3){
|
||||
return json(array('code'=>0,'msg'=>'返水出错'));
|
||||
}
|
||||
$startDate = Request::instance()->post('time_start');
|
||||
$endDate = Request::instance()->post('time_end');
|
||||
if($user_id > 0){
|
||||
// 查询要洗码的用户信息
|
||||
$user = Db::name('user')->where('id',$user_id)->find();
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'返水用户错误']));
|
||||
}
|
||||
|
||||
$rebateWhere = array();
|
||||
if($timeLength == 1 || $timeLength == 2){
|
||||
$startTime = strtotime($startDate);
|
||||
$endTime = strtotime($endDate);
|
||||
if($startTime > 0 && $endTime > 0){
|
||||
$rebateWhere['create_time'] = array('between',[$startTime,$endTime]);
|
||||
}else{
|
||||
return json(array('code'=>0,'msg'=>'请正确选择返水时间'));
|
||||
}
|
||||
}
|
||||
$rebateWhere['game_type'] = $gameType;
|
||||
$rebateWhere['user_id'] = $user['id'];
|
||||
$rebateWhere['is_checkout'] = 0;
|
||||
// 下注金额
|
||||
$amount = Db::name('rebate')->where($rebateWhere)->sum('amount');
|
||||
$rebate_amount_unbalanced = Db::name('rebate')->where($rebateWhere)->sum('rebate_amount_actual');
|
||||
// 验证返水
|
||||
if($rebate_amount_unbalanced <= 0){
|
||||
die(json_encode(['code'=>0,'msg'=>'未结返水必须要大于0!']));
|
||||
}
|
||||
|
||||
// 处理返水
|
||||
$money = $user['money'] + $rebate_amount_unbalanced;
|
||||
$result = Db::name('user')->where(['id'=>$user['id']])->update(['money'=>$money,'last_rebate_time'=>time()]);
|
||||
if(!$result){
|
||||
die(json_encode(['code'=>0,'msg'=>'返水失败!']));
|
||||
}
|
||||
// 更新返水表状态
|
||||
Db::name('rebate')->where($rebateWhere)->update(['is_checkout'=>1,'checkout_time'=>time()]);
|
||||
|
||||
// 处理返水
|
||||
$dataRebate = array();
|
||||
$dataRebate['game_type'] = $gameType;
|
||||
$dataRebate['user_id'] = $user['id'];
|
||||
$dataRebate['username'] = $user['username'];
|
||||
$dataRebate['admin_or_agent'] = 2;
|
||||
$dataRebate['controller_id'] = $user_info['id'];
|
||||
$dataRebate['controller_username'] = $user_info['username'];
|
||||
$dataRebate['amount'] = $amount;
|
||||
$dataRebate['rebate_amount'] = $rebate_amount_unbalanced;
|
||||
$dataRebate['rebate_rate'] = $user['rebate_rate'];
|
||||
$dataRebate['create_time'] = time();
|
||||
$dataRebate['old_money'] = $user['money'];
|
||||
$dataRebate['new_money'] = $money;
|
||||
Db::name('rebate_log')->insert($dataRebate);
|
||||
|
||||
// 处理上分
|
||||
$dataRecharge = array();
|
||||
$dataRecharge['type'] = 2;
|
||||
$dataRecharge['money'] = $rebate_amount_unbalanced;
|
||||
$dataRecharge['user_id'] = $user['id'];
|
||||
$dataRecharge['create_time'] = time();
|
||||
$dataRecharge['old_money'] = $user['money'];
|
||||
$dataRecharge['new_money'] = $money;
|
||||
Db::name('user_recharge')->insert($dataRecharge);
|
||||
|
||||
die(json_encode(['code'=>1,'msg'=>'返水成功']));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'操作错误!']));
|
||||
}
|
||||
}
|
||||
|
||||
// 添加充值提现页面
|
||||
public function recharge(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
Session::set('allowSubmit',"YES");
|
||||
// 获取管理员信息
|
||||
$user = Session::get('user_info');
|
||||
$account_type = $user['account_type'];
|
||||
$user = Db::name('user')->where('id',$user['id'])->find();
|
||||
$user['account_type'] = $account_type;
|
||||
if($user['account_type'] == 1){
|
||||
return $lang['illegal_request'];
|
||||
}
|
||||
$user = Db::name('user')->where('id',$user['id'])->find();
|
||||
$agentParentMoney = $user['money'];
|
||||
|
||||
// 接收需要修改的代理ID
|
||||
$id = Request::instance()->get('id');
|
||||
$user_info = Db::name('user')->where('id',$id)->find();
|
||||
|
||||
//送分限制
|
||||
$agent_parent_id_path_arr = explode(',',$user_info['agent_parent_id_path']);
|
||||
$agent_id_intersect = array_intersect(LEVEL_AGENT_ID,$agent_parent_id_path_arr);
|
||||
if(!empty($agent_id_intersect) && $user_info['agent'] == 0 && $user['agent_parent_id'] == 0){
|
||||
$this->assign('intersect',1);
|
||||
}else{
|
||||
$this->assign('intersect',0);
|
||||
}
|
||||
|
||||
//渲染参数和模板
|
||||
$this->assign('user_info',$user_info);
|
||||
$this->assign('agentParentMoney',$agentParentMoney);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 处理充值提现
|
||||
public function do_recharge(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::name('user')->where('id',$user_info['id'])->find();
|
||||
$user_info['account_type'] = $account_type;
|
||||
if($user_info['account_type'] == 1){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['illegal_request']]));
|
||||
}
|
||||
if(Request::instance()->post()){
|
||||
//防止重复提交
|
||||
$allowSubmit = Session::get('allowSubmit');
|
||||
if($allowSubmit == 'YES'){
|
||||
Session::delete('allowSubmit');
|
||||
}else{
|
||||
Session::delete('allowSubmit');
|
||||
return json(array('code' => 0, 'msg' => $lang['do_not_resubmit']));
|
||||
}
|
||||
// 接收数据
|
||||
$userId = Request::instance()->post('userId');
|
||||
$recharge = Request::instance()->post('recharge');
|
||||
$rechargeMoney = round(Request::instance()->post('rechargeMoney'),2);
|
||||
$rechargeGive = intval(Request::instance()->post('recharge_give'));
|
||||
$remake = Request::instance()->post('remake');
|
||||
if(isset($rechargeGive) && $rechargeGive == 1 && $recharge == 1){
|
||||
$type = 5;
|
||||
}else{
|
||||
$type = 1;
|
||||
}
|
||||
// 数据验证
|
||||
if($userId <= 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['error_id']]));
|
||||
}
|
||||
if($rechargeMoney <= 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['amount_big_than_0']]));
|
||||
}
|
||||
if($recharge == 1 && $rechargeMoney > $user_info['money']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['recharge_exceeds_limit'].' '.$user_info['money']]));
|
||||
}
|
||||
$user = Db::name('user')->where('id',$userId)->find();
|
||||
if($recharge == 2 && $rechargeMoney > $user['money']){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['insufficient_balance'].' '.$user['money'].'!']));
|
||||
}
|
||||
if($recharge == 1){
|
||||
$msgSuccess = $lang['recharged_successfully'];
|
||||
$msgFail = $lang['recharged_failed'];
|
||||
}elseif($recharge == 2){
|
||||
$msgSuccess = $lang['withdrawal_successful'];
|
||||
$msgFail = $lang['withdrawal_failed'];
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['wrong_r_w_type']]));
|
||||
}
|
||||
|
||||
// 用户更新余额
|
||||
$dataUser = array();
|
||||
$dataUser['id'] = $user['id'];
|
||||
if($recharge == 1){
|
||||
$dataUser['money'] = $user['money'] + $rechargeMoney;
|
||||
$dataUser['last_recharge'] = $rechargeMoney;
|
||||
$dataUser['last_recharge_time'] = time();
|
||||
$dataUser['recharge_count'] = $user['recharge_count'] + 1;
|
||||
$dataUser['recharge_total_amount'] = $user['recharge_total_amount'] + $rechargeMoney;
|
||||
}elseif($recharge == 2){
|
||||
$dataUser['money'] = $user['money'] - $rechargeMoney;
|
||||
}
|
||||
$updateResultUser = Db::name('user')->where('id',$user['id'])->update($dataUser);
|
||||
if(!$updateResultUser){
|
||||
die(json_encode(['code'=>0,'msg'=>$msgFail]));
|
||||
}
|
||||
// 管理员更新余额
|
||||
$dataController = array();
|
||||
$dataController['id'] = $user_info['id'];
|
||||
if($recharge == 1){
|
||||
$dataController['money'] = $user_info['money'] - $rechargeMoney;
|
||||
$dataController['last_recharge_out'] = $rechargeMoney;
|
||||
$dataController['last_recharge_out_time'] = time();
|
||||
$dataController['recharge_out_count'] = $user_info['recharge_out_count'] + 1;
|
||||
$dataController['recharge_out_total_amount'] = $user_info['recharge_out_total_amount'] + $rechargeMoney;
|
||||
}elseif($recharge == 2){
|
||||
$dataController['money'] = $user_info['money'] + $rechargeMoney;
|
||||
}
|
||||
$updateResultController = Db::name('user')->where('id',$user_info['id'])->update($dataController);
|
||||
if(!$updateResultController){
|
||||
// 恢复用户的余额(回滚)
|
||||
$dataUser = array();
|
||||
$dataUser['id'] = $user['id'];
|
||||
$dataUser['money'] = $user['money'];
|
||||
$dataUser['last_recharge'] = $user['last_recharge'];
|
||||
$dataUser['last_recharge_time'] = $user['last_recharge_time'];
|
||||
$dataUser['recharge_count'] = $user['recharge_count'];
|
||||
$dataUser['recharge_total_amount'] = $user['recharge_total_amount'];
|
||||
Db::name('user')->where('id',$user['id'])->update($dataUser);
|
||||
die(json_encode(['code'=>0,'msg'=>$msgFail]));
|
||||
}
|
||||
|
||||
// 记录充值/提现
|
||||
$dataRecharge = array();
|
||||
$dataRecharge['type'] = $type;
|
||||
$dataRecharge['amount'] = $rechargeMoney;
|
||||
$dataRecharge['mode'] = $recharge;
|
||||
$dataRecharge['agent_or_admin'] = 2;
|
||||
$dataRecharge['controller_id'] = $user_info['id'];
|
||||
$dataRecharge['controller_username'] = $user_info['username'];
|
||||
$dataRecharge['controller_nickname'] = $user_info['nickname'];
|
||||
$dataRecharge['controller_type'] = '代理系统操作';
|
||||
$dataRecharge['user_id'] = $user['id'];
|
||||
$dataRecharge['user_type'] = $user['agent'];
|
||||
$dataRecharge['user_agent_level'] = $user['agent_level'];
|
||||
$dataRecharge['username_for'] = $user['username'];
|
||||
$dataRecharge['nickname_for'] = $user['nickname'];
|
||||
$dataRecharge['user_parent_id'] = $user['agent_parent_id'];
|
||||
$dataRecharge['create_time'] = time();
|
||||
$dataRecharge['old_money'] = $user['money'];
|
||||
$dataRecharge['new_money'] = $dataUser['money'];
|
||||
$dataRecharge['controller_old_money'] = $user_info['money'];
|
||||
$dataRecharge['controller_new_money'] = $dataController['money'];
|
||||
$dataRecharge['controller_system'] = 1;
|
||||
$dataRecharge['remake'] = $remake;
|
||||
$result = Db::name('recharge')->insert($dataRecharge);
|
||||
if($result){
|
||||
die(json_encode(['code'=>1,'msg'=>$msgSuccess]));
|
||||
}else{
|
||||
// 恢复用户的余额
|
||||
$dataUser = array();
|
||||
$dataUser['id'] = $user['id'];
|
||||
$dataUser['money'] = $user['money'];
|
||||
$dataUser['last_recharge'] = $user['last_recharge'];
|
||||
$dataUser['last_recharge_time'] = $user['last_recharge_time'];
|
||||
$dataUser['recharge_count'] = $user['recharge_count'];
|
||||
$dataUser['recharge_total_amount'] = $user['recharge_total_amount'];
|
||||
Db::name('user')->where('id',$user['id'])->update($dataUser);
|
||||
|
||||
// 恢复管理员的余额
|
||||
$dataController = array();
|
||||
$dataController['id'] = $user_info['id'];
|
||||
$dataController['money'] = $user_info['money'];
|
||||
$dataController['last_recharge'] = $user_info['last_recharge'];
|
||||
$dataController['last_recharge_time'] = $user_info['last_recharge_time'];
|
||||
$dataController['recharge_count'] = $user_info['recharge_count'];
|
||||
$dataController['recharge_total_amount'] = $user_info['recharge_total_amount'];
|
||||
Db::name('user')->where('id',$user_info['id'])->update($dataController);
|
||||
|
||||
die(json_encode(['code'=>1,'msg'=>$msgFail]));
|
||||
}
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['operation_error']]));
|
||||
}
|
||||
}
|
||||
|
||||
// 抽水显示表
|
||||
public function commission(){
|
||||
Session::set('allowSubmit',"YES");
|
||||
// 接收洗码用户ID
|
||||
$user_id = Request::instance()->get('user_id');
|
||||
if($user_id > 0){
|
||||
// 获取查询代理信息
|
||||
$user_info = Db::name('user')->where('id',$user_id)->find();
|
||||
}else{
|
||||
die('代理抽水用户错误!');
|
||||
}
|
||||
|
||||
// 抽水数据
|
||||
$user_info['amount_commission'] = Db::name('agent_commission')->where(['agent_id'=>$user_info['id'],'is_checkout'=>0])->sum('amount');
|
||||
$user_info['agent_commission'] = Db::name('agent_commission')->where(['agent_id'=>$user_info['id'],'is_checkout'=>0])->order('id desc')->value('agent_commission');
|
||||
$user_info['money_commission'] = Db::name('agent_commission')->where(['agent_id'=>$user_info['id'],'is_checkout'=>0])->sum('money_commission');
|
||||
|
||||
// 最近抽水时间
|
||||
if($user_info['last_commission_time'] > 0){
|
||||
$user_info['last_commission_time'] = date('Y-m-d H:i:s',$user_info['last_commission_time']);
|
||||
}else{
|
||||
$user_info['last_commission_time'] = '-';
|
||||
}
|
||||
$user_info['agent_commission'] = round($user_info['agent_commission'],2);
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('user_info',$user_info);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 处理抽水
|
||||
public function do_commission(){
|
||||
if(Request::instance()->post()){
|
||||
//防止重复提交
|
||||
$allowSubmit = Session::get('allowSubmit');
|
||||
if($allowSubmit == 'YES'){
|
||||
Session::delete('allowSubmit');
|
||||
}else{
|
||||
Session::delete('allowSubmit');
|
||||
return json(array('code' => 0, 'msg' => "请勿重复提交"));
|
||||
}
|
||||
// 登录用户信息
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::name('user')->where('id',$user_info['id'])->find();
|
||||
$user_info['account_type'] = $account_type;
|
||||
|
||||
// 接收抽水用户ID
|
||||
$user_id = Request::instance()->post('user_id');
|
||||
$type_commission = Request::instance()->post('type_commission');
|
||||
if($user_id > 0){
|
||||
// 查询要抽水的用户信息
|
||||
$user = Db::name('user')->where('id',$user_id)->find();
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'抽水用户错误!']));
|
||||
}
|
||||
if(!in_array($type_commission,[1,2])){
|
||||
die(json_encode(['code'=>0,'msg'=>'请选择抽水方式!']));
|
||||
}
|
||||
|
||||
// 判断是不是直属
|
||||
if($user['agent_parent_id'] != $user_info['id']){
|
||||
die(json_encode(['code'=>0,'msg'=>'账号'.$user['username'].'不是您的直属下级,无法操作']));
|
||||
}
|
||||
// 抽水数据
|
||||
$amount_commission = Db::name('agent_commission')->where(['agent_id'=>$user['id'],'is_checkout'=>0])->sum('amount');
|
||||
$agent_commission = Db::name('agent_commission')->where(['agent_id'=>$user['id'],'is_checkout'=>0])->order('id desc')->value('agent_commission');
|
||||
$money_commission = Db::name('agent_commission')->where(['agent_id'=>$user['id'],'is_checkout'=>0])->sum('money_commission');
|
||||
// 验证抽水
|
||||
if($money_commission == 0){
|
||||
die(json_encode(['code'=>0,'msg'=>'抽水金额不能为0!']));
|
||||
}
|
||||
// 处理抽水(更新抽水时间)
|
||||
if($type_commission == 1){
|
||||
$moneycontrol = $user_info['money'] - $money_commission;
|
||||
if($moneycontrol < $money_commission){
|
||||
die(json_encode(['code'=>0,'msg'=>'余额不足!']));
|
||||
}
|
||||
Db::name('user')->where(['id'=>$user_info['id']])->update(['money'=>$moneycontrol]);
|
||||
$money = $user['money'] + $money_commission;
|
||||
$result = Db::name('user')->where(['id'=>$user['id']])->update(['money'=>$money,'last_commission_time'=>time()]);
|
||||
}else{
|
||||
$result = Db::name('user')->where(['id'=>$user['id']])->update(['last_commission_time'=>time()]);
|
||||
}
|
||||
if(!$result){
|
||||
die(json_encode(['code'=>0,'msg'=>'抽水失败!']));
|
||||
}
|
||||
|
||||
// 更新抽水状态
|
||||
Db::name('agent_commission')->where(['agent_id'=>$user['id'],'is_checkout'=>0])->update(['is_checkout'=>1,'checkout_time'=>time()]);
|
||||
// 处理抽水
|
||||
$dataCommission = array();
|
||||
$dataCommission['user_id'] = $user['id'];
|
||||
$dataCommission['username'] = $user['username'];
|
||||
$dataCommission['agent_id'] = $user['id'];
|
||||
$dataCommission['agent_username'] = $user['username'];
|
||||
$dataCommission['controller_id'] = $user_info['id'];
|
||||
$dataCommission['controller_username'] = $user_info['username'];
|
||||
$dataCommission['amount'] = $amount_commission;
|
||||
$dataCommission['agent_commission'] = $agent_commission;
|
||||
$dataCommission['money_commission'] = $money_commission;
|
||||
$dataCommission['type'] = $type_commission;
|
||||
$dataCommission['create_time'] = time();
|
||||
Db::name('agent_commission_log')->insert($dataCommission);
|
||||
|
||||
// 确定是充值还是提现
|
||||
if($money_commission > 0){
|
||||
$mode = 1;
|
||||
}elseif($money_commission < 0){
|
||||
$mode = 2;
|
||||
$money_commission = to_number($money_commission);
|
||||
}
|
||||
if($type_commission == 1){
|
||||
// 处理充值
|
||||
$dataRecharge = array();
|
||||
$dataRecharge['type'] = 6;
|
||||
$dataRecharge['amount'] = $money_commission;
|
||||
$dataRecharge['mode'] = $mode;
|
||||
$dataRecharge['agent_or_admin'] = 2;
|
||||
$dataRecharge['controller_id'] = $user_info['id'];
|
||||
$dataRecharge['controller_username'] = $user_info['username'];
|
||||
$dataRecharge['controller_nickname'] = $user_info['nickname'];
|
||||
$dataRecharge['controller_type'] = '代理系统操作';
|
||||
$dataRecharge['user_id'] = $user['id'];
|
||||
$dataRecharge['user_type'] = $user['agent'];
|
||||
$dataRecharge['user_agent_level'] = $user['agent_level'];
|
||||
$dataRecharge['username_for'] = $user['username'];
|
||||
$dataRecharge['nickname_for'] = $user['nickname'];
|
||||
$dataRecharge['user_parent_id'] = $user['agent_parent_id'];
|
||||
$dataRecharge['create_time'] = time();
|
||||
$dataRecharge['old_money'] = $user['money'];
|
||||
$dataRecharge['new_money'] = $user['money'] + $money_commission;
|
||||
$dataRecharge['controller_old_money'] = $user_info['money'];
|
||||
$dataRecharge['controller_new_money'] = $user_info['money'] - $money_commission;
|
||||
$dataRecharge['controller_system'] = 1;
|
||||
Db::name('recharge')->insert($dataRecharge);
|
||||
}
|
||||
die(json_encode(['code'=>1,'msg'=>'抽水成功']));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'操作错误!']));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,274 @@
|
||||
<?php
|
||||
namespace app\agent\controller;
|
||||
use \think\Controller;
|
||||
use think\Lang;
|
||||
use \think\Session;
|
||||
use \think\Request;
|
||||
use \think\Db;
|
||||
class Sub Extends Common{
|
||||
public function index(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
// 用于分页和搜索查询的数据
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get',$get);
|
||||
$this->assign('query',$query);
|
||||
|
||||
// 获取管理员信息
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::name('user')->where('id',$user_info['id'])->find();
|
||||
$user_info['account_type'] = $account_type;
|
||||
if($user_info['account_type'] == 1 ||$user_info['account_type'] == 2 || $user_info['account_type'] == 3){
|
||||
return $lang['illegal_request'];
|
||||
}
|
||||
$sub_list = Db::name('sub_account')->where('parent_id',$user_info['id'])->where('is_delete',0)->order('id asc')->paginate(15,false,['query'=>$get]);
|
||||
|
||||
foreach($sub_list as $k => $v){
|
||||
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
|
||||
if($v['account_type'] == 1){
|
||||
$v['account_type'] = $lang['account_management'];
|
||||
}else if($v['account_type'] == 2){
|
||||
$v['account_type'] = $lang['supply_and_drainage_management'];
|
||||
}else if($v['account_type'] == 3){
|
||||
$v['account_type'] = $lang['report_management'];
|
||||
}
|
||||
$sub_list[$k] = $v;
|
||||
}
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('user_info',$user_info);
|
||||
$this->assign('sub_list',$sub_list);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 添加子账户
|
||||
public function add_sub(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
// 获取管理员信息
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::name('user')->where('id',$user_info['id'])->find();
|
||||
$user_info['account_type'] = $account_type;
|
||||
if($user_info['account_type'] == 1 ||$user_info['account_type'] == 2 || $user_info['account_type'] == 3){
|
||||
return $lang['illegal_request'];
|
||||
}
|
||||
|
||||
//渲染参数和模板
|
||||
$this->assign('user_info',$user_info);
|
||||
return $this->fetch();
|
||||
}
|
||||
// 处理添加代理
|
||||
public function do_add(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::name('user')->where('id',$user_info['id'])->find();
|
||||
$user_info['account_type'] = $account_type;
|
||||
if($user_info['account_type'] == 1 ||$user_info['account_type'] == 2 || $user_info['account_type'] == 3){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['illegal_request']]));
|
||||
}
|
||||
if(Request::instance()->post()){
|
||||
// 接收参数
|
||||
$username = Request::instance()->post('username');
|
||||
$nickname = Request::instance()->post('nickname');
|
||||
$password = Request::instance()->post('password');
|
||||
$repassword = Request::instance()->post('repassword');
|
||||
$account_type = Request::instance()->post('account_type');
|
||||
|
||||
// 验证数据
|
||||
if(!$username){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['empty_username']]));
|
||||
}
|
||||
$user = Db::name('user')->where('username',$username)->find();
|
||||
if($user){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['already_exist_username']]));
|
||||
}
|
||||
if(!$nickname){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['empty_nickname']]));
|
||||
}
|
||||
if(!$password){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['empty_password']]));
|
||||
}
|
||||
if(strlen($password) < 6){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['new_pass_limit']]));
|
||||
}
|
||||
if($password != $repassword){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['pass_diff']]));
|
||||
}
|
||||
if($account_type > 3 && $account_type <= 0){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['account_function_error']]));
|
||||
}
|
||||
|
||||
// 拼装数据创建代理
|
||||
$user_data = array();
|
||||
$user_data['username'] = $username;
|
||||
$user_data['nickname'] = $nickname;
|
||||
$user_data['parent_id'] = $user_info['id'];
|
||||
$user_data['password'] = think_ucenter_md5($password, UC_AUTH_KEY);
|
||||
$user_data['account_type'] = $account_type;
|
||||
$user_data['create_time'] = time();
|
||||
$insertId = Db::name('sub_account')->insertGetId($user_data);
|
||||
if($insertId){
|
||||
// 写入管理员日志
|
||||
insertAgentLog('添加子账户','添加子账户:| ID: '.$insertId.' | 账号: '.$username);
|
||||
die(json_encode(['code'=>1,'msg'=>$lang['added_successfully']]));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['add_failed']]));
|
||||
}
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['operation_error']]));
|
||||
}
|
||||
}
|
||||
// 编辑子账户页面
|
||||
public function edit_sub(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::name('user')->where('id',$user_info['id'])->find();
|
||||
$user_info['account_type'] = $account_type;
|
||||
$id = Request::instance()->get('id');
|
||||
$sub_info = Db::name('sub_account')->where('id',$id)->where('parent_id',$user_info['id'])->find();
|
||||
//渲染参数和模板
|
||||
$this->assign('user_info',$user_info);
|
||||
$this->assign('sub_info',$sub_info);
|
||||
return $this->fetch();
|
||||
}
|
||||
// 处理编辑子账户
|
||||
public function do_edit(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::name('user')->where('id',$user_info['id'])->find();
|
||||
$user_info['account_type'] = $account_type;
|
||||
if($user_info['account_type'] == 1 ||$user_info['account_type'] == 2 || $user_info['account_type'] == 3){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['illegal_request']]));
|
||||
}
|
||||
if(Request::instance()->post()){
|
||||
// 接收参数
|
||||
$id = Request::instance()->post('sub_id');
|
||||
$nickname = Request::instance()->post('nickname');
|
||||
$password = trim(Request::instance()->post('password'));
|
||||
$repassword = Request::instance()->post('repassword');
|
||||
$account_type = Request::instance()->post('account_type');
|
||||
// 拼装数据创建代理
|
||||
$user_data = array();
|
||||
// 验证数据
|
||||
if(!$nickname){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['empty_nickname']]));
|
||||
}else{
|
||||
$user_data['nickname'] = $nickname;
|
||||
}
|
||||
if(!$account_type){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['select_account_function']]));
|
||||
}else{
|
||||
$user_data['account_type'] = $account_type;
|
||||
}
|
||||
if($password){
|
||||
if(strlen($password) < 6){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['new_pass_limit']]));
|
||||
}
|
||||
if($password != $repassword){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['pass_diff']]));
|
||||
}
|
||||
$user_data['password'] = think_ucenter_md5($password, UC_AUTH_KEY);
|
||||
}
|
||||
$result = Db::name('sub_account')->where('id',$id)->update($user_data);
|
||||
if($result){
|
||||
// 写入管理员日志
|
||||
$user = Db::name('sub_account')->where('id',$id)->find();
|
||||
insertAgentLog('编辑子账户','编辑子账户:| ID: '.$user['id'].' | 账号: '.$user['username']);
|
||||
}
|
||||
die(json_encode(['code'=>1,'msg'=>$lang['edit_successfully']]));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['edit_failed']]));
|
||||
}
|
||||
}
|
||||
//删除子账户
|
||||
public function do_del(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::name('user')->where('id',$user_info['id'])->find();
|
||||
$user_info['account_type'] = $account_type;
|
||||
if($user_info['account_type'] == 1 ||$user_info['account_type'] == 2 || $user_info['account_type'] == 3){
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['illegal_request']]));
|
||||
}
|
||||
if(Request::instance()->post()){
|
||||
// 接收参数
|
||||
$id = Request::instance()->post('sub_id');
|
||||
$result = Db::name('sub_account')->where('id',$id)->update(['is_delete' => 1]);
|
||||
if($result){
|
||||
// 写入管理员日志
|
||||
$user = Db::name('sub_account')->where('id',$id)->find();
|
||||
insertAgentLog('删除子账户','删除子账户| ID: '.$user['id'].' | 账号: '.$user['username']);
|
||||
}
|
||||
die(json_encode(['code'=>1,'msg'=>$lang['deleted_successfully']]));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>$lang['operation_error']]));
|
||||
}
|
||||
}
|
||||
public function delete(){
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
// 获取管理员信息
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::name('user')->where('id',$user_info['id'])->find();
|
||||
$user_info['account_type'] = $account_type;
|
||||
if($user_info['account_type'] == 1 ||$user_info['account_type'] == 2 || $user_info['account_type'] == 3){
|
||||
return $lang['illegal_request'];
|
||||
}
|
||||
$sub_list = Db::name('sub_account')->where('parent_id',$user_info['id'])->where('is_delete',1)->order('id asc')->select();
|
||||
|
||||
foreach($sub_list as $k => $v){
|
||||
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
|
||||
if($v['account_type'] == 1){
|
||||
$v['account_type'] = $lang['account_management'];
|
||||
}else if($v['account_type'] == 2){
|
||||
$v['account_type'] = $lang['supply_and_drainage_management'];
|
||||
}else if($v['account_type'] == 3){
|
||||
$v['account_type'] = $lang['report_management'];
|
||||
}
|
||||
$sub_list[$k] = $v;
|
||||
}
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('user_info',$user_info);
|
||||
$this->assign('sub_list',$sub_list);
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
namespace app\agent\controller;
|
||||
use \think\Controller;
|
||||
use \think\Session;
|
||||
use \think\Request;
|
||||
use \think\Db;
|
||||
use \think\paginator\driver\Bootstrap;
|
||||
class Withdraw Extends Common{
|
||||
// 提现查询
|
||||
public function withdraw(){
|
||||
// 登录用户信息
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::connect('DB2')->name('user')->where('id',$user_info['id'])->find();
|
||||
$user_info['account_type'] = $account_type;
|
||||
if($user_info['account_type'] == 1){
|
||||
return '非法请求';
|
||||
}
|
||||
|
||||
|
||||
// 用于分页和搜索查询的数据
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get',$get);
|
||||
$this->assign('query',$query);
|
||||
|
||||
// 接收参数
|
||||
$startDate = Request::instance()->get('startDate');
|
||||
$endDate = Request::instance()->get('endDate');
|
||||
$username = Request::instance()->get('username');
|
||||
|
||||
// 转换日期时间
|
||||
if($startDate){
|
||||
$startTime = strtotime($startDate);
|
||||
}else{
|
||||
$startTime = 0;
|
||||
}
|
||||
if($endDate){
|
||||
$endTime = strtotime($endDate);
|
||||
}else{
|
||||
$endTime = time();
|
||||
}
|
||||
|
||||
// 拼装搜索条件
|
||||
$where = array();
|
||||
$where['create_time'] = array('between',[$startTime,$endTime]);
|
||||
if($username){
|
||||
$user = Db::name('user')->where(['username'=>$username,'is_delete'=>0])->find();
|
||||
if($user){
|
||||
$where['user_id'] = $user['id'];
|
||||
}else{
|
||||
$where['user_id'] = 0;
|
||||
}
|
||||
}
|
||||
if($user_info['agent_parent_id'] > 0){
|
||||
$list = Db::name('user_withdraw')
|
||||
->alias('r')
|
||||
->field('r.*,u.username,u.nickname')
|
||||
->join('cg_user u','r.user_id=u.id and (u.agent_parent_id_path like "%,'.$user_info['id'].',%" or r.user_id='.$user_info['id'].')')
|
||||
->where($where)
|
||||
->order('r.id desc')
|
||||
->paginate(20,false,array('query'=>$get));
|
||||
}else{
|
||||
$list = Db::name('user_withdraw')
|
||||
->alias('r')
|
||||
->field('r.*,u.username,u.nickname')
|
||||
->join('cg_user u','r.user_id=u.id and (u.agent_parent_id_path like "'.$user_info['id'].',%" or r.user_id='.$user_info['id'].')')
|
||||
->where($where)
|
||||
->order('r.id desc')
|
||||
->paginate(20,false,array('query'=>$get));
|
||||
}
|
||||
|
||||
// 提现状态
|
||||
$status = [
|
||||
'SUCCESS' => "提现成功",
|
||||
'FAIL' => "提现失败",
|
||||
'WAIT' => "等待审核",
|
||||
'AGREE' => "已同意",
|
||||
'DISAGREE' => "已拒绝",
|
||||
'CANCEL' => "已取消",
|
||||
];
|
||||
foreach($list as $k => $v){
|
||||
// 信息组装
|
||||
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
|
||||
// 提现状态
|
||||
$v['status_msg'] = $status[$v['status']];
|
||||
|
||||
// 操作类型
|
||||
if($v['operator_source'] == 1){
|
||||
$v['operator_source_msg'] = '总台操作';
|
||||
}else if($v['operator_source'] == 2){
|
||||
$v['operator_source_msg'] = '代理操作';
|
||||
}else{
|
||||
$v['operator_source_msg'] = '';
|
||||
}
|
||||
// 数据格式转换
|
||||
$v['amount'] = round($v['amount'],2);
|
||||
$v['old_money'] = round($v['old_money'],2);
|
||||
$v['new_money'] = round($v['new_money'],2);
|
||||
$list[$k] = $v;
|
||||
}
|
||||
// pre($list);
|
||||
// 汇总金额
|
||||
if($user_info['agent_parent_id'] > 0){
|
||||
$total = Db::name('user_withdraw')
|
||||
->alias('r')
|
||||
->field('sum(r.amount) as amount, sum(r.service_fee) as service_fee, sum(r.money) as money')
|
||||
->join('cg_user u','r.user_id=u.id and (u.agent_parent_id_path like "%,'.$user_info['id'].',%" or r.user_id='.$user_info['id'].')')
|
||||
->where($where)->find();
|
||||
}else{
|
||||
$total = Db::name('user_withdraw')
|
||||
->alias('r')
|
||||
->field('sum(r.amount) as amount, sum(r.service_fee) as service_fee, sum(r.money) as money')
|
||||
->join('cg_user u','r.user_id=u.id and (u.agent_parent_id_path like "'.$user_info['id'].',%" or r.user_id='.$user_info['id'].')')
|
||||
->where($where)
|
||||
->find();
|
||||
}
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('list',$list);
|
||||
$this->assign('user_info',$user_info);
|
||||
$this->assign('total',$total);
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
namespace app\agent\controller;
|
||||
use \think\Controller;
|
||||
use \think\Session;
|
||||
use \think\Request;
|
||||
use \think\Db;
|
||||
use think\Config;
|
||||
class Wt Extends Common{
|
||||
public function index(){
|
||||
// 登录用户信息
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::name('user')->where('id',$user_info['id'])->find();
|
||||
$referral_code = $user_info['referral_code'];
|
||||
$user_info['account_type'] = $account_type;
|
||||
// 推广链接
|
||||
|
||||
|
||||
$tables = Db::connect('DB2')->name('table')->where(array('status' => 1))->order('game_id asc')->select();
|
||||
$wt_agent = Db::connect('DB2')->name('table')->where(array('status' => 1))->order('id asc')->limit(1)->value('wt_agent');
|
||||
$agent_list = Config::get('wt_list');
|
||||
$serverName = WT_STATIC_DOMAIN;
|
||||
|
||||
if(!$wt_agent){
|
||||
$marketingUrl = '(请先请选择运行路线)';
|
||||
}else{
|
||||
$wt_agent_info = Db::name('user')->where(['username'=>$wt_agent])->find();
|
||||
if($wt_agent_info['referral_code']){
|
||||
$marketingUrl = $serverName.'?referral_code='.$wt_agent_info['referral_code'];
|
||||
}else{
|
||||
$referral_code = getRandCode();
|
||||
$marketingUrl = $serverName.'?referral_code='.$referral_code;
|
||||
Db::name('user')->where(['username'=>$wt_agent])->update(['referral_code'=>$referral_code]);
|
||||
}
|
||||
// if(!$wt_agent_info['line_url']){
|
||||
// // 推广链接
|
||||
// $ask = array();
|
||||
// $ask['appid'] = 139663876;
|
||||
// $ask['appkey'] = 'f6d0f6090f7652bf509e96c51189298f';
|
||||
// $ask['type'] = 'add';
|
||||
// $ask['url'] = $marketingUrl;
|
||||
// $ask['visit_type'] = 'jump';
|
||||
// $url = 'https://wechaturl.us/api/SingleShortUrl.json';
|
||||
// $postdata = @http_build_query($ask);
|
||||
// $options = array(
|
||||
// 'http' => array(
|
||||
// 'method' => 'POST',
|
||||
// 'header' => 'Content-type:application/x-www-form-urlencoded',
|
||||
// 'content' => $postdata,
|
||||
// 'timeout' => 15 * 60 // 超时时间(单位:s)
|
||||
// )
|
||||
// );
|
||||
// $context = stream_context_create($options);
|
||||
// $result = file_get_contents($url, false, $context);
|
||||
// $result = json_decode($result);
|
||||
// $result = ((array)$result);
|
||||
// if($result['code'] == 1){
|
||||
// $resultdata = ((array)$result['data']);
|
||||
// $marketingUrl = $resultdata['weibo_shorturl'];
|
||||
// DB::name('user')->where('id',$wt_agent_info['id'])->update(['line_url' => $marketingUrl]);
|
||||
// }else{
|
||||
// return '生成推广码失败,请稍后再试';
|
||||
// }
|
||||
// }else{
|
||||
// $marketingUrl = $wt_agent_info['line_url'];
|
||||
// }
|
||||
|
||||
}
|
||||
// 渲染
|
||||
$this->assign('user_info',$user_info);
|
||||
$this->assign('wt_agent',$wt_agent);
|
||||
$this->assign('agent_list',$agent_list);
|
||||
$this->assign('tables',$tables);
|
||||
$this->assign('marketingUrl',$marketingUrl);
|
||||
return $this->fetch();
|
||||
}
|
||||
public function do_wt_table(){
|
||||
$table_str = Request::instance()->post('table_str');
|
||||
Db::name('table')->where('is_wt',1)->update(['is_wt' => 0]);
|
||||
if($table_str){
|
||||
$table_str = rtrim($table_str, ',');
|
||||
$table_arr = explode(",", $table_str);
|
||||
Db::name('table')->whereIn('id',$table_arr)->update(['is_wt' => 1]);
|
||||
}
|
||||
return json(array('Success' => 0, 'Msg' => '修改成功'));
|
||||
}
|
||||
public function do_wt_agent(){
|
||||
$wt_agent = Request::instance()->post('wt_agent');
|
||||
if($wt_agent == '0'){
|
||||
return json(array('Success' => 0, 'Msg' => '请选择运行路线'));
|
||||
}else{
|
||||
$serverName = WT_STATIC_DOMAIN;
|
||||
$wt_agent_info = Db::name('user')->where(['username'=>$wt_agent])->find();
|
||||
if($wt_agent_info['referral_code']){
|
||||
$marketingUrl = $serverName.'?referral_code='.$wt_agent_info['referral_code'];
|
||||
}else{
|
||||
$referral_code = getRandCode();
|
||||
$marketingUrl = $serverName.'?referral_code='.$referral_code;
|
||||
Db::name('user')->where(['username'=>$wt_agent])->update(['referral_code'=>$referral_code]);
|
||||
}
|
||||
Db::name('table')->where(array('status' => 1))->update(['wt_agent' => $wt_agent]);
|
||||
// if(!$wt_agent_info['line_url']){
|
||||
// // 推广链接
|
||||
// $ask = array();
|
||||
// $ask['appid'] = 139663876;
|
||||
// $ask['appkey'] = 'f6d0f6090f7652bf509e96c51189298f';
|
||||
// $ask['type'] = 'add';
|
||||
// $ask['url'] = $marketingUrl;
|
||||
// $ask['visit_type'] = 'jump';
|
||||
// $url = 'https://wechaturl.us/api/SingleShortUrl.json';
|
||||
// $postdata = @http_build_query($ask);
|
||||
// $options = array(
|
||||
// 'http' => array(
|
||||
// 'method' => 'POST',
|
||||
// 'header' => 'Content-type:application/x-www-form-urlencoded',
|
||||
// 'content' => $postdata,
|
||||
// 'timeout' => 15 * 60 // 超时时间(单位:s)
|
||||
// )
|
||||
// );
|
||||
// $context = stream_context_create($options);
|
||||
// $result = file_get_contents($url, false, $context);
|
||||
// $result = json_decode($result);
|
||||
// $result = ((array)$result);
|
||||
// if($result['code'] == 1){
|
||||
// $resultdata = ((array)$result['data']);
|
||||
// $marketingUrl = $resultdata['weibo_shorturl'];
|
||||
// DB::name('user')->where('id',$wt_agent_info['id'])->update(['line_url' => $marketingUrl]);
|
||||
// }else{
|
||||
// return '生成推广码失败,请稍后再试';
|
||||
// }
|
||||
// }else{
|
||||
// $marketingUrl = $wt_agent_info['line_url'];
|
||||
// }
|
||||
return json(array('Success' => 1, 'Msg' => '修改成功','url' => $marketingUrl));
|
||||
}
|
||||
}
|
||||
|
||||
public function line_marketing(){
|
||||
// 登录用户信息
|
||||
$user_info = Session::get('user_info');
|
||||
$account_type = $user_info['account_type'];
|
||||
$user_info = Db::name('user')->where('id',$user_info['id'])->find();
|
||||
$referral_code = $user_info['referral_code'];
|
||||
$user_info['account_type'] = $account_type;
|
||||
if(!$user_info['referral_code']){//没有推荐码则补充
|
||||
$referral_code = getRandCode();
|
||||
Db::name('user')->where(['id'=>$user_info['id']])->update(['referral_code'=>$referral_code]);
|
||||
}
|
||||
$user_info['referral_code'] = $referral_code;
|
||||
|
||||
$serverName = WT_STATIC_DOMAIN;
|
||||
$marketingUrl = $serverName.'?referral_code='.$referral_code;
|
||||
// if(!$user_info['line_url']){
|
||||
// // 推广链接
|
||||
// $serverName = WT_STATIC_DOMAIN;
|
||||
// $marketingUrl = $serverName.'?referral_code='.$referral_code;
|
||||
// $ask = array();
|
||||
// $ask['appid'] = 139663876;
|
||||
// $ask['appkey'] = 'f6d0f6090f7652bf509e96c51189298f';
|
||||
// $ask['type'] = 'add';
|
||||
// $ask['url'] = $marketingUrl;
|
||||
// $ask['visit_type'] = 'jump';
|
||||
// $url = 'https://wechaturl.us/api/SingleShortUrl.json';
|
||||
// $postdata = @http_build_query($ask);
|
||||
// $options = array(
|
||||
// 'http' => array(
|
||||
// 'method' => 'POST',
|
||||
// 'header' => 'Content-type:application/x-www-form-urlencoded',
|
||||
// 'content' => $postdata,
|
||||
// 'timeout' => 15 * 60 // 超时时间(单位:s)
|
||||
// )
|
||||
// );
|
||||
// $context = stream_context_create($options);
|
||||
// $result = file_get_contents($url, false, $context);
|
||||
// $result = json_decode($result);
|
||||
// $result = ((array)$result);
|
||||
// if($result['code'] == 1){
|
||||
// $resultdata = ((array)$result['data']);
|
||||
// $marketingUrl = $resultdata['weibo_shorturl'];
|
||||
// DB::name('user')->where('id',$user_info['id'])->update(['line_url' => $marketingUrl]);
|
||||
// }else{
|
||||
// return '生成推广码失败,请稍后再试';
|
||||
// }
|
||||
// }else{
|
||||
// $marketingUrl = $user_info['line_url'];
|
||||
// }
|
||||
|
||||
|
||||
// 渲染
|
||||
$this->assign('user_info',$user_info);
|
||||
$this->assign('marketingUrl',$marketingUrl);
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user