Pro/application/agent/controller/Login.php
li 1ce6c3d780 feat: 牛牛新增四条(炸弹)赔率配置 price_bomb
- 后台管理: Player/Agent 控制器新增接收、验证、保存
- 后台页面: player/agent 添加/编辑/列表页新增赔率字段
- 代理端: 继承/展示 price_bomb
- 预测赔率: jk/Pcapi/onlinechip 新增 bomb_forecast
- Betinfo: 新增 result==12 赔率查询

数据库需执行:
ALTER TABLE cg_user ADD COLUMN price_bomb float(5,2) NOT NULL DEFAULT 4.85 COMMENT '四条赔率' AFTER price_5n;
2026-02-11 17:32:41 +08:00

428 lines
16 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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).'&nbsp;&nbsp;';
}
if($v['player_amount'] > 0){
$v['bet_detail'] .= ' 闲'.round($v['player_amount'],2).'&nbsp;&nbsp;';
}
if($v['tie_amount'] > 0){
$v['bet_detail'] .= ' 和'.round($v['tie_amount'],2).'&nbsp;&nbsp;';
}
if($v['banker_pair_amount'] > 0){
$v['bet_detail'] .= ' 庄对'.round($v['banker_pair_amount'],2).'&nbsp;&nbsp;';
}
if($v['player_pair_amount'] > 0){
$v['bet_detail'] .= ' 闲对'.round($v['player_pair_amount'],2).'&nbsp;&nbsp;';
}
$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).'&nbsp;&nbsp;';
}
if($v['player_amount'] > 0){
$v['bet_detail'] .= ' 虎'.round($v['player_amount'],2).'&nbsp;&nbsp;';
}
if($v['tie_amount'] > 0){
$v['bet_detail'] .= ' 和'.round($v['tie_amount'],2).'&nbsp;&nbsp;';
}
$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;
//其它语言
}
}
}