init: 从宝塔同步到 Gitea
This commit is contained in:
@@ -0,0 +1,297 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\Db;
|
||||
use think\Request;
|
||||
|
||||
class Admin extends Common{
|
||||
public function index(){
|
||||
// 接收分页的条件
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get',$get);
|
||||
$this->assign('query',$query);
|
||||
|
||||
// 接收搜索的条件信息
|
||||
$username = Request::instance()->get('username');
|
||||
$status = Request::instance()->get('status');
|
||||
$startDate = Request::instance()->get('startDate');
|
||||
$endDate = Request::instance()->get('endDate');
|
||||
$export = Request::instance()->get('export');
|
||||
$startTime = 0;
|
||||
$endTime = time();
|
||||
|
||||
// 拼装搜索条件
|
||||
$where = array();
|
||||
if(!empty($username)) $where['admin'] = array('like',"%".$username."%");
|
||||
if($status > 0){
|
||||
// 锁定不能用0作为判断,用2代替
|
||||
if($status == 2){
|
||||
$where['status'] = 0;
|
||||
}else{
|
||||
$where['status'] = $status;
|
||||
}
|
||||
}
|
||||
if($startDate) $startTime = strtotime($startDate);
|
||||
if($endDate) $endTime = strtotime($endDate);
|
||||
$where['create_time'] = array('between',[$startTime,$endTime]);
|
||||
$where['is_delete'] = 0;
|
||||
|
||||
if($export == 1){
|
||||
$admin_list = Db::name('admin')->where($where)->order('create_time desc')->select();
|
||||
}else{
|
||||
// 所有总台管理员列表
|
||||
$admin_list = Db::name('admin')->where($where)->order('create_time desc')->paginate(10,false,array('query'=>$get));
|
||||
}
|
||||
foreach($admin_list as $k => $v){
|
||||
$v['last_login_time'] = date('Y-m-d H:i:s',$v['last_login_time']);
|
||||
$admin_list[$k] = $v;
|
||||
}
|
||||
|
||||
//导出excel列表
|
||||
if($export == 1){
|
||||
if($admin_list){
|
||||
//重新组合
|
||||
$excelData = array();
|
||||
foreach($admin_list AS $k => $v){
|
||||
$excelData[$k][0] = $v['admin'];
|
||||
$excelData[$k][1] = $v['mobile'];
|
||||
$excelData[$k][2] = $v['email'];
|
||||
$excelData[$k][3] = $v['last_login_ip'];
|
||||
$excelData[$k][4] = $v['last_login_time'];
|
||||
if($v['status'] == 1){
|
||||
$excelData[$k][5] = '正常';
|
||||
}else{
|
||||
$excelData[$k][5] = '锁定中';
|
||||
}
|
||||
}
|
||||
$title = array('用户名','电话','邮箱','最后登录IP','最后登录时间','状态');
|
||||
if($startDate && $endDate){
|
||||
$this->exportExcelCore($excelData, '用户列表-'.$startDate."至".$endDate, $title);
|
||||
}else{
|
||||
$this->exportExcelCore($excelData, '用户列表', $title);
|
||||
}
|
||||
exit('已导出支持列表,请不要重复刷新该页面!');
|
||||
}else{
|
||||
exit('没有可以导出的列表!');
|
||||
}
|
||||
}
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('admin_list',$admin_list);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 添加总台管理员页面
|
||||
public function admin_add(){
|
||||
return $this->fetch('admin-add');
|
||||
}
|
||||
|
||||
// 处理添加总台管理员
|
||||
public function do_admin_add(){
|
||||
// 接收提交过来的数据
|
||||
$username = Request::instance()->post('username');
|
||||
$pass = Request::instance()->post('pass');
|
||||
$repass = Request::instance()->post('repass');
|
||||
$mobile = Request::instance()->post('mobile');
|
||||
$email = Request::instance()->post('email');
|
||||
$status = Request::instance()->post('status');
|
||||
$remarks = Request::instance()->post('remarks');
|
||||
|
||||
// 数据验证
|
||||
if( !isset($username) && empty($username) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'用户名不能为空!']));
|
||||
}
|
||||
if( !isset($pass) && empty($pass) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'密码不能为空!']));
|
||||
}
|
||||
if( !isset($repass) && empty($repass) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'确认密码不能为空!']));
|
||||
}
|
||||
if( $repass != $pass ){
|
||||
die(json_encode(['code'=>0,'msg'=>'两次密码不一致!']));
|
||||
}
|
||||
|
||||
// 检测用户名是否已经被注册
|
||||
$user = Db::name('admin')->where('admin',$username)->find();
|
||||
if($user){
|
||||
die(json_encode(['code'=>0,'msg'=>'用户已存在!']));
|
||||
}
|
||||
|
||||
// 拼装数据
|
||||
$data = array();
|
||||
$data['admin'] = $username;
|
||||
$data['password'] = think_ucenter_md5($pass, UC_AUTH_KEY);
|
||||
$data['mobile'] = $mobile;
|
||||
$data['email'] = $email;
|
||||
$data['status'] = $status;
|
||||
$data['remark'] = $remarks;
|
||||
$data['is_delete'] = 0;
|
||||
$data['create_time'] = time();
|
||||
$insert_id = Db::name('admin')->insertGetId($data);
|
||||
if($insert_id){
|
||||
// 写入管理员日志
|
||||
insertAdminLog('添加管理员','添加管理员:| ID: '.$insert_id.' | 账号: '.$username);
|
||||
die(json_encode(['code'=>1,'msg'=>'添加成功!']));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'添加失败!']));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑管理员页面
|
||||
*/
|
||||
public function admin_edit()
|
||||
{
|
||||
// 接收代理ID,查询代理信息
|
||||
$id = Request::instance()->get('id');
|
||||
$admin = Db::name('admin')->find($id);
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('admin',$admin);
|
||||
return $this->fetch('/admin/admin-edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理修改管理员信息
|
||||
*/
|
||||
public function do_admin_edit()
|
||||
{
|
||||
if(Request::instance()->post()){
|
||||
// 接收传过来的数据
|
||||
$admin_id = Request::instance()->post('admin_id');
|
||||
$username = Request::instance()->post('username');
|
||||
$pass = Request::instance()->post('pass');
|
||||
$repass = Request::instance()->post('repass');
|
||||
$mobile = Request::instance()->post('mobile');
|
||||
$email = Request::instance()->post('email');
|
||||
$remarks = Request::instance()->post('remarks');
|
||||
|
||||
//数据验证
|
||||
if(empty($username)){
|
||||
die(json_encode(['code'=>0,'msg'=>'账号不能为空!']));
|
||||
}
|
||||
if(!empty($pass) && strlen($pass) < 6){
|
||||
die(json_encode(['code'=>0,'msg'=>'密码长度不能少于6位!']));
|
||||
}
|
||||
if(!empty($pass) && $pass != $repass){
|
||||
die(json_encode(['code'=>0,'msg'=>'两次密码输入不一致!']));
|
||||
}
|
||||
if( !isset($mobile) && empty($mobile) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'手机号码不能为空!']));
|
||||
}
|
||||
|
||||
// 拼装数据
|
||||
$data = array();
|
||||
$data['admin'] = $username;
|
||||
if(!empty($pass)) $data['password'] = think_ucenter_md5($pass, UC_AUTH_KEY);
|
||||
$data['mobile'] = $mobile;
|
||||
$data['email'] = $email;
|
||||
$data['remark'] = $remarks;
|
||||
$data['update_time'] = time();
|
||||
|
||||
// 修改管理员资料
|
||||
$result = Db::name('admin')->where('id',$admin_id)->update($data);
|
||||
if($result){
|
||||
insertAdminLog('修改代理','修改代理:| ID: '.$admin_id.' | 账号:'.$username);
|
||||
die(json_encode(['code'=>1,'msg'=>'修改成功!']));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'修改失败!']));
|
||||
}
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'操作错误!']));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户状态(锁定和解锁用户)
|
||||
*/
|
||||
public function change_status()
|
||||
{
|
||||
if(Request::instance()->post()){
|
||||
// 接收传过来的数据
|
||||
$user_id = Request::instance()->post('user_id');
|
||||
$status = Request::instance()->post('status');
|
||||
|
||||
// 数据验证
|
||||
if( !isset($user_id) && empty($user_id) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'用户不能为空!']));
|
||||
}
|
||||
if( !isset($status) && empty($status) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'状态不能为空!']));
|
||||
}
|
||||
|
||||
// 修改用户状态
|
||||
$result = Db::name('admin')->where('id',$user_id)->update(['status'=>$status]);
|
||||
if($status == 1) $msg = "解锁";
|
||||
if($status == 0) $msg = "锁定";
|
||||
if($result){
|
||||
insertAdminLog($msg."代理",$msg."代理: | ID: ".$user_id);
|
||||
die(json_encode(['code'=>1,'msg'=>$msg.'成功!']));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>$msg.'失败!']));
|
||||
}
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'操作错误!']));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除管理员
|
||||
*/
|
||||
public function admin_del()
|
||||
{
|
||||
if(Request::instance()->post()){
|
||||
// 接收数据
|
||||
$user_id = Request::instance()->post('user_id');
|
||||
|
||||
// 数据验证
|
||||
if(!$user_id){
|
||||
die(json_encode(['code'=>0,'msg'=>'用户不存在']));
|
||||
}
|
||||
|
||||
// 删除用户
|
||||
$result = Db::name('admin')->where('id',$user_id)->update(['is_delete'=>1]);
|
||||
if($result){
|
||||
insertAdminLog('删除代理',"删除代理: | ID: ".$user_id);
|
||||
die(json_encode(['code'=>1,'msg'=>'删除成功!']));
|
||||
}else{
|
||||
die(json_encode(['code'=>1,'msg'=>'删除失败!']));
|
||||
}
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'操作错误!']));
|
||||
}
|
||||
}
|
||||
public function admin_print(){
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$username = Request::instance()->get('username');
|
||||
$status = Request::instance()->get('status');
|
||||
$startDate = Request::instance()->get('startDate');
|
||||
$endDate = Request::instance()->get('endDate');
|
||||
$startTime = 0;
|
||||
$endTime = time();
|
||||
$where = array();
|
||||
if(!empty($username)) $where['admin'] = array('like',"%".$username."%");
|
||||
if($status > 0){
|
||||
// 锁定不能用0作为判断,用2代替
|
||||
if($status == 2){
|
||||
$where['status'] = 0;
|
||||
}else{
|
||||
$where['status'] = $status;
|
||||
}
|
||||
}
|
||||
if($startDate) $startTime = strtotime($startDate);
|
||||
if($endDate) $endTime = strtotime($endDate);
|
||||
$where['create_time'] = array('between',[$startTime,$endTime]);
|
||||
$where['is_delete'] = 0;
|
||||
$admin_list = Db::name('admin')->where($where)->order('create_time desc')->select();
|
||||
foreach($admin_list as $k => $v){
|
||||
$v['last_login_time'] = date('Y-m-d H:i:s',$v['last_login_time']);
|
||||
$admin_list[$k] = $v;
|
||||
}
|
||||
$this->assign('admin_list',$admin_list);
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
Executable
+1395
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,721 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use \think\Controller;
|
||||
use \think\Request;
|
||||
use \think\Db;
|
||||
use \think\Lang;
|
||||
use \think\Session;
|
||||
use \think\Log;
|
||||
|
||||
class Apicloud extends Controller{
|
||||
private function do_opening_dt($numberTab,$z){
|
||||
$game_id = $numberTab['game_id'];
|
||||
$table_id = $numberTab['table_id'];
|
||||
$table_info = Db::name('table')->where(array('id' => $table_id))->find();
|
||||
$boot_id = $numberTab['boot_id'];
|
||||
$opening = $z['result'];
|
||||
$pair = $z['pair'];
|
||||
$bets = Db::name('bet')->where(array('number_tab_id' => $numberTab['id']))->select();
|
||||
$oBets = $bets;
|
||||
if(!empty($oBets)){
|
||||
foreach($bets AS $key => $value){
|
||||
$bet_win_total = $value['win_total'];
|
||||
Db::execute("update `cg_user` set `money` = `money` - ".$bet_win_total." where `id`=".$value['user_id'].' limit 1');
|
||||
}
|
||||
//删除上一铺下注、洗码、分成
|
||||
$vid = Db::name('bet')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $numberTab['id']))->delete();
|
||||
Db::name('xima')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $numberTab['id']))->delete();
|
||||
Db::name('cs')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $numberTab['id']))->delete();
|
||||
Db::name('agent_commission')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $numberTab['id']))->delete();
|
||||
Db::name('number_tab')->where(array('id' => $numberTab['id']))->limit(1)->update(array('result' => $opening));
|
||||
//记录修改日志
|
||||
$retreated_log_data = array();
|
||||
$retreated_log_data['mode'] = 1;
|
||||
$retreated_log_data['type'] = 1;
|
||||
$retreated_log_data['create_time'] = time();
|
||||
$retreated_log_data['gamei_id'] = $game_id;
|
||||
$retreated_log_data['table_id'] = $table_id;
|
||||
$retreated_log_data['table_name'] = $numberTab['table_name'];
|
||||
$retreated_log_data['boot_id'] = $boot_id;
|
||||
$retreated_log_data['boot_num'] = $numberTab['boot_num'];
|
||||
$retreated_log_data['number_tab_id'] = $numberTab['id'];
|
||||
$retreated_log_data['number'] = $numberTab['number'];
|
||||
$str = '';
|
||||
if($numberTab['result'] == 1) $str = '龙';
|
||||
if($numberTab['result'] == 2) $str = '虎';
|
||||
if($numberTab['result'] == 3) $str = '和';
|
||||
$nstr = '';
|
||||
if($opening == 1) $nstr = '龙';
|
||||
if($opening == 2) $nstr = '虎';
|
||||
if($opening == 3) $nstr = '和';
|
||||
$retreated_log_data['remark'] = '该口原本结果为:'.$str.',更改为:'.$nstr;
|
||||
Db::name('retreated_log')->insert($retreated_log_data);
|
||||
foreach($oBets AS $k => $v){
|
||||
$user_info = Db::name('user')->where(array('id' => intval($v['user_id'])))->find();
|
||||
$agent_commission = $user_info['agent_commission_dt'] / 100;
|
||||
if($user_info){
|
||||
$amount = 0;
|
||||
$amount = $v['banker_amount'] + $v['player_amount'] + $v['tie_amount'];
|
||||
$win_money = 0;
|
||||
// 双边洗码
|
||||
$ximaliang = 0;
|
||||
if($user_info['type_xima'] == 1){
|
||||
$ximaliang = $v['banker_amount'] - $v['player_amount'];
|
||||
$ximaliang = abs($ximaliang);
|
||||
}
|
||||
// 龙赢
|
||||
if ($opening == 1) {
|
||||
if($v['banker_amount'] > 0){
|
||||
$win_money = round($v['banker_amount'] * (1 + $user_info['price_dragon'] - $agent_commission),2) + $win_money;
|
||||
}
|
||||
// 单边洗码
|
||||
if($user_info['type_xima'] == 2){
|
||||
$ximaliang = $v['player_amount'];
|
||||
}
|
||||
}
|
||||
// 虎赢
|
||||
if ($opening == 2 && $v['player_amount'] > 0) {
|
||||
$win_money = round($v['player_amount'] * (1 + $user_info['price_tiger'] - $agent_commission),2) + $win_money;
|
||||
// 单边洗码
|
||||
if($user_info['type_xima'] == 2){
|
||||
$ximaliang = $v['banker_amount'];
|
||||
}
|
||||
}
|
||||
// 和
|
||||
if ($opening == 3) {
|
||||
$win_money = $v['banker_amount'] + $v['player_amount'] + $win_money;
|
||||
$ximaliang = 0;
|
||||
if($v['tie_amount'] > 0){
|
||||
$win_money = $v['tie_amount'] * (1 + $user_info['price_tie_dt']) + $win_money;
|
||||
}
|
||||
}
|
||||
// 计算最终赢钱还是输钱
|
||||
$win_total = $win_money - $amount;
|
||||
//更新user表余额
|
||||
if($v['result'] == 0){
|
||||
$money = $user_info['money'] + $win_total + $amount;
|
||||
}else{
|
||||
$money = $user_info['money'] + $win_total;
|
||||
}
|
||||
Db::name('user')->where(array('id' => $user_info['id']))->update(array('money' => $money));
|
||||
//更新bet表
|
||||
$insertV = $v;
|
||||
unset($insertV['id']);
|
||||
$insertBetData = $insertV;
|
||||
$insertBetData['result'] = $opening;
|
||||
$insertBetData['win_total'] = $win_total;
|
||||
if($v['result'] > 0){
|
||||
$insertBetData['is_edit'] = 1;
|
||||
}else{
|
||||
$insertBetData['is_edit'] = 0;
|
||||
}
|
||||
$insertBetData['is_end'] = 1;
|
||||
Db::name('bet')->insert($insertBetData);
|
||||
//写入cs表
|
||||
$agent = explode(',', $user_info['agent_parent_id_path']); //切割多个代理ID为数组
|
||||
krsort($agent);
|
||||
$nextCs = 0;
|
||||
$nextMaliang = 0;
|
||||
foreach($agent as $key => $value){
|
||||
$user_path_info = Db::name('user')->where(array('id' => $value))->find();
|
||||
if($user_path_info){
|
||||
$maliang = 0;
|
||||
$ximalv = $user_path_info['agent_ximalv_dt'];
|
||||
$maliang_true = 0;
|
||||
if($ximalv > 0 && $ximaliang > 0){
|
||||
$type = $key == 0 ? 1 : 0;
|
||||
$maliang = round(($ximaliang * $ximalv) / 100,2);
|
||||
$maliang_true = $maliang;
|
||||
if($user_path_info['agent_cs'] > 0 && $user_path_info['share_xima'] == 2){
|
||||
$maliang_true = $maliang - round($maliang * ($user_path_info['agent_cs'] / 100),2);
|
||||
}
|
||||
$net_maliang = $maliang - $nextMaliang;
|
||||
$nextMaliang = $net_maliang + $nextMaliang;
|
||||
$insert_xima_sql = "INSERT INTO `cg_xima` (`user_id`,`bet_user_id`,`bet_id`,`game_id`,`table_id`,`sumday_id`,`day`,`number_tab_id`,`boot_id`,`ximaliang`,`ximalv`,`maliang`,`maliang_true`,`total`,`win_total`,`create_time`,`type`,`net_maliang`) VALUES (".$value.",".$user_info['id'].",".$v['id'].",".$v['game_id'].",".$v['table_id'].",".$v['sumday_id'].",'".$v['day']."',".$v['number_tab_id'].",".$v['boot_id'].",".$ximaliang.",".$ximalv.",".$maliang.",".$maliang_true.",".$amount.",".$win_total.",".$v['create_time'].",".$type.",".$net_maliang.")";
|
||||
Db::execute($insert_xima_sql);
|
||||
}
|
||||
//if($user_path_info['agent_cs'] > 0){
|
||||
$type = $key == 0 ? 1 : 0;
|
||||
$share_amount = to_number(round(($user_path_info['agent_cs'] * $win_total) / 100,2));
|
||||
if($user_path_info['agent_cs'] > 0){
|
||||
$share_amount_true = round(to_number($maliang + $win_total) * ($user_path_info['agent_cs'] / 100),2);
|
||||
}else{
|
||||
$share_amount_true = $maliang;
|
||||
}
|
||||
$net_cs = $share_amount - $nextCs;
|
||||
$nextCs = $net_cs + $nextCs;
|
||||
$insert_cs_sql = "INSERT INTO `cg_cs` (`user_id`,`bet_user_id`,`bet_id`,`game_id`,`table_id`,`number_tab_id`,`boot_id`,`sumday_id`,`day`,`share_amount`,`share_amount_true`,`share_percent`,`total`,`win_total`,`create_time`,`type`,`net_cs`,`maliang`) VALUES (".$value.",".$user_info['id'].",".$v['id'].",".$v['game_id'].",".$v['table_id'].",".$v['number_tab_id'].",".$v['boot_id'].",".$v['sumday_id'].",'".$v['day']."',".$share_amount.",".$share_amount_true.",".$user_path_info['agent_cs'].",".$amount.",".$win_total.",".$v['create_time'].",".$type.",".$net_cs.",".$maliang.")";
|
||||
Db::execute($insert_cs_sql);
|
||||
//}
|
||||
}
|
||||
}
|
||||
// 代理抽水
|
||||
if($opening == 1 && $v['banker_amount'] > 0 && $user_info['agent_commission'] > 0){
|
||||
$parentIdPath = explode(',',$user_info['agent_parent_id_path']);
|
||||
foreach($parentIdPath as $value){
|
||||
$user = Db::name('user')->where('id',$value)->find();
|
||||
$insert_commission_sql = "INSERT INTO `cg_agent_commission` (`user_id`,`username`,`agent_id`,`agent_username`,`game_id`,`game_name`,`table_id`,`table_name`,`boot_id`,`boot_num`,`number_tab_id`,`number`,`bet_id`,`amount`,`agent_commission`,`money_commission`,`result`,`create_time`) VALUES (".$user['id'].",'".$user['username']."',".$user['agent_parent_id'].",'".$user['agent_parent_username']."',2,'龙虎',".$table_info['id'].",'".$table_info['table_name']."',".$v['boot_id'].",".$v['boot_num'].",".$v['number_tab_id'].",".$v['number'].",".$v['id'].",".$v['banker_amount'].",".$agent_commission.",".$v['banker_amount'] * $agent_commission.",".$opening.",".$v['create_time'].")";
|
||||
Db::execute($insert_commission_sql);
|
||||
}
|
||||
}
|
||||
if($opening == 2 && $v['player_amount'] > 0 && $user_info['agent_commission'] > 0){
|
||||
$parentIdPath = explode(',',$user_info['agent_parent_id_path']);
|
||||
foreach($parentIdPath as $value){
|
||||
$user = Db::name('user')->where('id',$value)->find();
|
||||
$insert_commission_sql = "INSERT INTO `cg_agent_commission` (`user_id`,`username`,`agent_id`,`agent_username`,`game_id`,`game_name`,`table_id`,`table_name`,`boot_id`,`boot_num`,`number_tab_id`,`number`,`bet_id`,`amount`,`agent_commission`,`money_commission`,`result`,`create_time`) VALUES (".$user['id'].",'".$user['username']."',".$user['agent_parent_id'].",'".$user['agent_parent_username']."',2,'龙虎',".$table_info['id'].",'".$table_info['table_name']."',".$v['boot_id'].",".$v['boot_num'].",".$v['number_tab_id'].",".$v['number'].",".$v['id'].",".$v['player_amount'].",".$user_info['agent_commission'].",".$v['player_amount'] * $agent_commission.",".$opening.",".$v['create_time'].")";
|
||||
Db::execute($insert_commission_sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private function do_opening_baccarat_win6($numberTab,$z){
|
||||
$game_id = $numberTab['game_id'];
|
||||
$table_id = $numberTab['table_id'];
|
||||
$boot_id = $numberTab['boot_id'];
|
||||
$opening = $z['result'];
|
||||
$pair = $z['pair'];
|
||||
$win6 = $z['win6'];
|
||||
$bets = Db::name('bet')->where(array('number_tab_id' => $numberTab['id'], 'status' => 1))->select();
|
||||
$oBets = $bets;
|
||||
if(!empty($oBets)){
|
||||
foreach($bets AS $key => $value){
|
||||
$bet_win_total = $value['win_total'];
|
||||
Db::execute("update `cg_user` set `money` = `money` - ".$bet_win_total." where `id`=".$value['user_id'].' limit 1');
|
||||
}
|
||||
//删除上一铺下注、洗码、分成
|
||||
Db::name('bet')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $numberTab['id']))->delete();
|
||||
Db::name('xima')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $numberTab['id']))->delete();
|
||||
Db::name('cs')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $numberTab['id']))->delete();
|
||||
Db::name('number_tab')->where(array('id' => $numberTab['id']))->limit(1)->update(array('result' => $opening, 'pair' => $pair, 'win6' => $win6));
|
||||
//记录修改日志
|
||||
$retreated_log_data = array();
|
||||
$retreated_log_data['mode'] = 1;
|
||||
$retreated_log_data['type'] = 1;
|
||||
$retreated_log_data['create_time'] = time();
|
||||
$retreated_log_data['gamei_id'] = $game_id;
|
||||
$retreated_log_data['table_id'] = $table_id;
|
||||
$retreated_log_data['table_name'] = $numberTab['table_name'];
|
||||
$retreated_log_data['boot_id'] = $boot_id;
|
||||
$retreated_log_data['boot_num'] = $numberTab['boot_num'];
|
||||
$retreated_log_data['number_tab_id'] = $number_tab_id;
|
||||
$retreated_log_data['number'] = $numberTab['number'];
|
||||
$str = '';
|
||||
if($numberTab['result'] == 1) $str = '庄';
|
||||
if($numberTab['result'] == 2) $str = '闲';
|
||||
if($numberTab['result'] == 3) $str = '和';
|
||||
if($numberTab['pair'] == 1) $str = $str.'-庄对';
|
||||
if($numberTab['pair'] == 2) $str = $str.'-闲对';
|
||||
if($numberTab['pair'] == 3) $str = $str.'-庄闲对';
|
||||
if($numberTab['win6'] == 1) $str = $str.'-赢6';
|
||||
$nstr = '';
|
||||
if($opening == 1) $nstr = '庄';
|
||||
if($opening == 2) $nstr = '闲';
|
||||
if($opening == 3) $nstr = '和';
|
||||
if($pair == 1) $nstr = $nstr.'-庄对';
|
||||
if($pair == 2) $nstr = $nstr.'-闲对';
|
||||
if($pair == 3) $nstr = $nstr.'-庄闲对';
|
||||
if($isWin6 == 1) $nstr = $nstr.'-赢6';
|
||||
$retreated_log_data['remark'] = '该口原本结果为:'.$str.',更改为:'.$nstr;
|
||||
Db::name('retreated_log')->insert($retreated_log_data);
|
||||
foreach($oBets AS $k => $v){
|
||||
$user_info = Db::name('user')->field(array('id','money','agent_parent_id_path'))->where(array('id' => intval($v['user_id'])))->find();
|
||||
if($user_info){
|
||||
$amount = 0;
|
||||
$amount = $v['banker_amount'] + $v['player_amount'] + $v['tie_amount'] + $v['banker_pair_amount'] + $v['player_pair_amount'];
|
||||
$win_money = 0;
|
||||
$BPT_ximaliang = 0;
|
||||
if($opening == 1){
|
||||
// 庄赢
|
||||
if($v['banker_amount'] > 0){
|
||||
if($isWin6 === 1){
|
||||
$win_money = $v['banker_amount'] * (1 + 0.5) + $win_money;
|
||||
}else{
|
||||
$win_money = $v['banker_amount'] * (1 + 1) + $win_money;
|
||||
}
|
||||
}
|
||||
$BPT_ximaliang = $v['player_amount'] + $v['tie_amount'];
|
||||
}elseif($opening == 2){
|
||||
// 闲赢
|
||||
if($v['player_amount'] > 0){
|
||||
if($isWin6 === 1){
|
||||
$win_money = $v['player_amount'] * (1 + 0.5) + $win_money;
|
||||
}else{
|
||||
$win_money = $v['player_amount'] * (1 + 1) + $win_money;
|
||||
}
|
||||
}
|
||||
$BPT_ximaliang = $v['banker_amount'] + $v['tie_amount'];
|
||||
}elseif($opening == 3) {
|
||||
// 和赢
|
||||
if($v['tie_amount'] > 0){
|
||||
$win_money = $v['tie_amount'] * (1 + 8) + $win_money;
|
||||
}
|
||||
// 开 和,下注庄和闲不扣钱
|
||||
if($v['banker_amount'] > 0 && $v['player_amount'] > 0){
|
||||
$win_money = $v['player_amount'] + $v['banker_amount'] + $win_money;
|
||||
}elseif($v['banker_amount'] > 0){
|
||||
$win_money = $v['banker_amount'] + $win_money;
|
||||
} elseif ($v['player_amount'] > 0){
|
||||
$win_money = $v['player_amount'] + $win_money;
|
||||
}
|
||||
}
|
||||
if($pair == 3){
|
||||
// 计算庄对下注的赢钱金额
|
||||
if ($v['banker_pair_amount'] > 0) {
|
||||
$win_money = $v['banker_pair_amount'] * (1 + 11) + $win_money;
|
||||
}
|
||||
//计算闲对下注的赢钱金额
|
||||
if ($v['player_pair_amount'] > 0) {
|
||||
$win_money = $v['player_pair_amount'] * (1 + 11) + $win_money;
|
||||
}
|
||||
}elseif($pair == 1){
|
||||
if ($v['banker_pair_amount'] > 0) {
|
||||
$win_money = $v['banker_pair_amount'] * (1 + 11) + $win_money;
|
||||
}
|
||||
}elseif($pair == 2){
|
||||
if ($v['player_pair_amount'] > 0) {
|
||||
$win_money = $v['player_pair_amount'] * (1 + 11) + $win_money;
|
||||
}
|
||||
}
|
||||
// 计算最终赢钱还是输钱
|
||||
$win_total = $win_money - $amount;
|
||||
//更新user表余额
|
||||
if($v['result'] == 0){
|
||||
$money = $user_info['money'] + $win_total + $amount;
|
||||
}else{
|
||||
$money = $user_info['money'] + $win_total;
|
||||
}
|
||||
Db::name('user')->where(array('id' => $user_info['id']))->update(array('money' => $money));
|
||||
//更新bet表
|
||||
$insertV = $v;
|
||||
unset($insertV['id']);
|
||||
$insertBetData = $insertV;
|
||||
$insertBetData['result'] = $opening;
|
||||
$insertBetData['pair'] = $pair;
|
||||
$insertBetData['win_total'] = $win_total;
|
||||
if($v['result'] > 0){
|
||||
$insertBetData['is_edit'] = 1;
|
||||
}else{
|
||||
$insertBetData['is_edit'] = 0;
|
||||
}
|
||||
$insertBetData['is_end'] = 1;
|
||||
Db::name('bet')->insert($insertBetData);
|
||||
//写入cs表
|
||||
$agent = explode(',', $user_info['agent_parent_id_path']); //切割多个代理ID为数组
|
||||
krsort($agent);
|
||||
$nextCs = 0;
|
||||
foreach($agent as $key => $value){
|
||||
$user_path_info = Db::name('user')->where(array('id' => $value))->find();
|
||||
if($user_path_info){
|
||||
if($user_path_info['agent_cs'] > 0){
|
||||
$type = $key == 0 ? 1 : 0;
|
||||
$share_amount = to_number(($user_path_info['agent_cs'] * $win_total) / 100);
|
||||
$share_amount_true = 0;
|
||||
$net_cs = $share_amount - $share_amount;
|
||||
$nextCs = $net_cs + $nextCs;
|
||||
$insert_cs_sql = "INSERT INTO `cg_cs` (`user_id`,`bet_user_id`,`bet_id`,`game_id`,`table_id`,`number_tab_id`,`boot_id`,`sumday_id`,`day`,`share_amount`,`share_amount_true`,`share_percent`,`total`,`win_total`,`create_time`,`type`,`net_cs`) VALUES (".$value.",".$user_info['id'].",".$v['id'].",".$v['game_id'].",".$v['table_id'].",".$v['number_tab_id'].",".$v['boot_id'].",".$v['sumday_id'].",'".$v['day']."',".$share_amount.",".$share_amount_true.",".$user_path_info['agent_cs'].",".$amount.",".$win_total.",".time().",".$type.",".$net_cs.")";
|
||||
Db::execute($insert_cs_sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private function do_opening_baccarat($numberTab,$z){
|
||||
$game_id = $numberTab['game_id'];
|
||||
$table_id = $numberTab['table_id'];
|
||||
$table_info = Db::name('table')->where(array('id' => $table_id))->find();
|
||||
$boot_id = $numberTab['boot_id'];
|
||||
$opening = $z['result'];
|
||||
$pair = $z['pair'];
|
||||
$bets = Db::name('bet')->where(array('number_tab_id' => $numberTab['id'], 'status' => 1))->select();
|
||||
$oBets = $bets;
|
||||
if(!empty($oBets)){
|
||||
foreach($bets AS $key => $value){
|
||||
$bet_win_total = $value['win_total'];
|
||||
Db::execute("update `cg_user` set `money` = `money` - ".$bet_win_total." where `id`=".$value['user_id'].' limit 1');
|
||||
}
|
||||
//删除上一铺下注、洗码、分成
|
||||
Db::name('bet')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $numberTab['id']))->delete();
|
||||
Db::name('xima')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $numberTab['id']))->delete();
|
||||
Db::name('cs')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $numberTab['id']))->delete();
|
||||
Db::name('agent_commission')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $numberTab['id']))->delete();
|
||||
Db::name('number_tab')->where(array('id' => $numberTab['id']))->limit(1)->update(array('result' => $opening, 'pair' => $pair));
|
||||
//记录修改日志
|
||||
$retreated_log_data = array();
|
||||
$retreated_log_data['mode'] = 1;
|
||||
$retreated_log_data['type'] = 1;
|
||||
$retreated_log_data['create_time'] = time();
|
||||
$retreated_log_data['gamei_id'] = $game_id;
|
||||
$retreated_log_data['table_id'] = $table_id;
|
||||
$retreated_log_data['table_name'] = $numberTab['table_name'];
|
||||
$retreated_log_data['boot_id'] = $boot_id;
|
||||
$retreated_log_data['boot_num'] = $numberTab['boot_num'];
|
||||
$retreated_log_data['number_tab_id'] = $numberTab['id'];
|
||||
$retreated_log_data['number'] = $numberTab['number'];
|
||||
$str = '';
|
||||
if($numberTab['result'] == 1) $str = '庄';
|
||||
if($numberTab['result'] == 2) $str = '闲';
|
||||
if($numberTab['result'] == 3) $str = '和';
|
||||
if($numberTab['pair'] == 1) $str = $str.'-庄对';
|
||||
if($numberTab['pair'] == 2) $str = $str.'-闲对';
|
||||
if($numberTab['pair'] == 3) $str = $str.'-庄闲对';
|
||||
$nstr = '';
|
||||
if($opening == 1) $nstr = '庄';
|
||||
if($opening == 2) $nstr = '闲';
|
||||
if($opening == 3) $nstr = '和';
|
||||
if($pair == 1) $nstr = $nstr.'-庄对';
|
||||
if($pair == 2) $nstr = $nstr.'-闲对';
|
||||
if($pair == 3) $nstr = $nstr.'-庄闲对';
|
||||
$retreated_log_data['remark'] = '该口原本结果为:'.$str.',更改为:'.$nstr;
|
||||
Db::name('retreated_log')->insert($retreated_log_data);
|
||||
foreach($oBets AS $k => $v){
|
||||
$user_info = Db::name('user')->where(array('id' => intval($v['user_id'])))->find();
|
||||
$agent_commission = $user_info['agent_commission'] / 100;
|
||||
if($user_info){
|
||||
$amount = 0;
|
||||
$amount = $v['banker_amount'] + $v['player_amount'] + $v['tie_amount'] + $v['banker_pair_amount'] + $v['player_pair_amount'];
|
||||
$win_money = 0;
|
||||
// 双边洗码
|
||||
$ximaliang = 0;
|
||||
if($user_info['type_xima'] == 1){
|
||||
$ximaliang = $v['banker_amount'] - $v['player_amount'];
|
||||
$ximaliang = abs($ximaliang);
|
||||
}
|
||||
if($opening == 1){
|
||||
// 庄赢
|
||||
if($v['banker_amount'] > 0){
|
||||
if($table_info['mode'] == 1){
|
||||
$win_money = round($v['banker_amount'] * (1 + $user_info['price_banker'] - $agent_commission),2) + $win_money;
|
||||
}else{
|
||||
$win_money = round($v['banker_amount'] * (1 + $user_info['price_banker']),2) + $win_money;
|
||||
}
|
||||
}
|
||||
// 单边洗码
|
||||
if($user_info['type_xima'] == 2){
|
||||
$ximaliang = $v['player_amount'];
|
||||
}
|
||||
}elseif($opening == 2){
|
||||
// 闲赢
|
||||
if($v['player_amount'] > 0){
|
||||
$win_money = $v['player_amount'] * (1 + $user_info['price_player']) + $win_money;
|
||||
}
|
||||
// 单边洗码
|
||||
if($user_info['type_xima'] == 2){
|
||||
$ximaliang = $v['banker_amount'];
|
||||
}
|
||||
}elseif($opening == 3) {
|
||||
$ximaliang = 0;
|
||||
// 和赢
|
||||
if($v['tie_amount'] > 0){
|
||||
$win_money = $v['tie_amount'] * (1 + $user_info['price_tie_baccarat']) + $win_money;
|
||||
}
|
||||
// 开 和,下注庄和闲不扣钱
|
||||
if($v['banker_amount'] > 0 && $v['player_amount'] > 0){
|
||||
$win_money = $v['player_amount'] + $v['banker_amount'] + $win_money;
|
||||
}elseif($v['banker_amount'] > 0){
|
||||
$win_money = $v['banker_amount'] + $win_money;
|
||||
} elseif ($v['player_amount'] > 0){
|
||||
$win_money = $v['player_amount'] + $win_money;
|
||||
}
|
||||
}
|
||||
if($pair == 3){
|
||||
// 计算庄对下注的赢钱金额
|
||||
if ($v['banker_pair_amount'] > 0) {
|
||||
$win_money = $v['banker_pair_amount'] * (1 + $user_info['price_pair']) + $win_money;
|
||||
}
|
||||
//计算闲对下注的赢钱金额
|
||||
if ($v['player_pair_amount'] > 0) {
|
||||
$win_money = $v['player_pair_amount'] * (1 + $user_info['price_pair']) + $win_money;
|
||||
}
|
||||
}elseif($pair == 1){
|
||||
if ($v['banker_pair_amount'] > 0) {
|
||||
$win_money = $v['banker_pair_amount'] * (1 + $user_info['price_pair']) + $win_money;
|
||||
}
|
||||
}elseif($pair == 2){
|
||||
if ($v['player_pair_amount'] > 0) {
|
||||
$win_money = $v['player_pair_amount'] * (1 + $user_info['price_pair']) + $win_money;
|
||||
}
|
||||
}
|
||||
// 计算最终赢钱还是输钱
|
||||
$win_total = $win_money - $amount;
|
||||
//更新user表余额
|
||||
if($v['result'] == 0){
|
||||
$money = $user_info['money'] + $win_total + $amount;
|
||||
}else{
|
||||
$money = $user_info['money'] + $win_total;
|
||||
}
|
||||
Db::name('user')->where(array('id' => $user_info['id']))->update(array('money' => $money));
|
||||
//更新bet表
|
||||
$insertV = $v;
|
||||
unset($insertV['id']);
|
||||
$insertBetData = $insertV;
|
||||
$insertBetData['result'] = $opening;
|
||||
$insertBetData['pair'] = $pair;
|
||||
$insertBetData['win_total'] = $win_total;
|
||||
if($v['result'] > 0){
|
||||
$insertBetData['is_edit'] = 1;
|
||||
}else{
|
||||
$insertBetData['is_edit'] = 0;
|
||||
}
|
||||
$insertBetData['is_end'] = 1;
|
||||
Db::name('bet')->insert($insertBetData);
|
||||
//写入码率表及cs表
|
||||
$agent = explode(',', $user_info['agent_parent_id_path']);
|
||||
krsort($agent);
|
||||
$nextCs = 0;
|
||||
$nextMaliang = 0;
|
||||
foreach($agent as $key => $value){
|
||||
$user_path_info = Db::name('user')->where(array('id' => $value))->find();
|
||||
if($user_path_info){
|
||||
$maliang = 0;
|
||||
$ximalv = $user_path_info['agent_ximalv'];
|
||||
$maliang_true = 0;
|
||||
if($ximalv > 0 && $ximaliang > 0){
|
||||
$type = $key == 0 ? 1 : 0;
|
||||
$maliang = round(($ximaliang * $ximalv) / 100,2);
|
||||
$maliang_true = $maliang;
|
||||
if($user_path_info['agent_cs'] > 0 && $user_path_info['share_xima'] == 2){
|
||||
$maliang_true = $maliang - round($maliang * ($user_path_info['agent_cs'] / 100),2);
|
||||
}
|
||||
$net_maliang = $maliang - $nextMaliang;
|
||||
$nextMaliang = $net_maliang + $nextMaliang;
|
||||
$insert_xima_sql = "INSERT INTO `cg_xima` (`user_id`,`bet_user_id`,`bet_id`,`game_id`,`table_id`,`sumday_id`,`day`,`number_tab_id`,`boot_id`,`ximaliang`,`ximalv`,`maliang`,`maliang_true`,`total`,`win_total`,`create_time`,`type`,`net_maliang`) VALUES (".$value.",".$user_info['id'].",".$v['id'].",".$v['game_id'].",".$v['table_id'].",".$v['sumday_id'].",'".$v['day']."',".$v['number_tab_id'].",".$v['boot_id'].",".$ximaliang.",".$ximalv.",".$maliang.",".$maliang_true.",".$amount.",".$win_total.",".$v['create_time'].",".$type.",".$net_maliang.")";
|
||||
Db::execute($insert_xima_sql);
|
||||
}
|
||||
//if($user_path_info['agent_cs'] > 0){
|
||||
$type = $key == 0 ? 1 : 0;
|
||||
$share_amount = to_number(($user_path_info['agent_cs'] * $win_total) / 100);
|
||||
if($user_path_info['agent_cs'] > 0){
|
||||
$share_amount_true = round(to_number($maliang + $win_total) * ($user_path_info['agent_cs'] / 100),2);
|
||||
}else{
|
||||
$share_amount_true = $maliang;
|
||||
}
|
||||
$net_cs = $share_amount - $nextCs;
|
||||
$nextCs = $net_cs + $nextCs;
|
||||
$insert_cs_sql = "INSERT INTO `cg_cs` (`user_id`,`bet_user_id`,`bet_id`,`game_id`,`table_id`,`number_tab_id`,`boot_id`,`sumday_id`,`day`,`share_amount`,`share_amount_true`,`share_percent`,`total`,`win_total`,`create_time`,`type`,`net_cs`,`maliang`) VALUES (".$value.",".$user_info['id'].",".$v['id'].",".$v['game_id'].",".$v['table_id'].",".$v['number_tab_id'].",".$v['boot_id'].",".$v['sumday_id'].",'".$v['day']."',".$share_amount.",".$share_amount_true.",".$user_path_info['agent_cs'].",".$amount.",".$win_total.",".$v['create_time'].",".$type.",".$net_cs.",".$maliang.")";
|
||||
Db::execute($insert_cs_sql);
|
||||
//}
|
||||
}
|
||||
}
|
||||
// 代理抽水
|
||||
if($opening == 1 && $v['banker_amount'] > 0 && $user_info['agent_commission'] > 0 ){
|
||||
$parentIdPath = explode(',',$user_info['agent_parent_id_path']);
|
||||
foreach($parentIdPath as $value){
|
||||
$user = Db::name('user')->where('id',$value)->find();
|
||||
$insert_commission_sql = "INSERT INTO `cg_agent_commission` (`user_id`,`username`,`agent_id`,`agent_username`,`game_id`,`game_name`,`table_id`,`table_name`,`boot_id`,`boot_num`,`number_tab_id`,`number`,`bet_id`,`amount`,`agent_commission`,`money_commission`,`result`,`pair`,`create_time`) VALUES (".$user['id'].",'".$user['username']."',".$user['agent_parent_id'].",'".$user['agent_parent_username']."',1,'百家乐',".$table_info['id'].",'".$table_info['table_name']."',".$v['boot_id'].",".$v['boot_num'].",".$v['number_tab_id'].",".$v['number'].",".$v['id'].",".$v['banker_amount'].",".$user_info['agent_commission'].",".$v['banker_amount'] * $agent_commission.",".$opening.",".$pair.",".$v['create_time'].")";
|
||||
Db::execute($insert_commission_sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public function get_number_tab_id(){
|
||||
if(Request::instance()->isPost()){
|
||||
$table_id = intval(Request::instance()->post('online_table_id'));
|
||||
$table_token = Request::instance()->post('table_token');
|
||||
$local_day = Request::instance()->post('day');
|
||||
$local_boot_num = intval(Request::instance()->post('boot_num'));
|
||||
$local_number = intval(Request::instance()->post('number'));
|
||||
if($table_id > 0 && $local_day && $local_boot_num > 0 && $local_number > 0){
|
||||
$table = Db::name('table')->where(array('id' => $table_id))->find();
|
||||
$game_id = $table['game_id'];
|
||||
if($game_id == 1){
|
||||
$bootTableName = 'boot';
|
||||
$numberTabTableName = 'number_tab';
|
||||
$betTableName = 'bet';
|
||||
}elseif($game_id == 2){
|
||||
$bootTableName = 'boot';
|
||||
$numberTabTableName = 'number_tab';
|
||||
$betTableName = 'bet';
|
||||
}else{
|
||||
return json(array('Success' => 0, 'Msg' => 'game_error'));
|
||||
}
|
||||
if($table['table_token'] == $table_token){
|
||||
$lastNumberTab = Db::name($numberTabTableName)->where(array('table_id' => $table_id))->order('id DESC')->find();
|
||||
//var_dump($local_day);
|
||||
//echo "<br>";
|
||||
//var_dump($local_boot_num);
|
||||
//echo "<br>";
|
||||
//var_dump($local_number);
|
||||
//echo "<br>";
|
||||
//echo "<pre>";
|
||||
//var_dump($lastNumberTab);
|
||||
//echo "</pre>";
|
||||
if($lastNumberTab){
|
||||
if($local_day == $lastNumberTab['day'] && $lastNumberTab['boot_num'] == $local_boot_num && $lastNumberTab['number'] == $local_number){
|
||||
return json(array('Success' => 1, 'lastNumberTabId' => $lastNumberTab['id']));
|
||||
}else{
|
||||
return json(array('Success' => 0, 'Msg' => 'bet_status_error'));
|
||||
}
|
||||
}else{
|
||||
return json(array('Success' => 0, 'Msg' => 'not_number_tab'));
|
||||
}
|
||||
}else{
|
||||
return json(array('Success' => 0, 'Msg' => 'table_error'));
|
||||
}
|
||||
}else{
|
||||
return json(array('Success' => 0, 'Msg' => 'post_error'));
|
||||
}
|
||||
}
|
||||
}
|
||||
public function sync_data(){
|
||||
if(Request::instance()->isPost()){
|
||||
$post = Request::instance()->post();
|
||||
$data = unserialize($post['data']);
|
||||
$localTable = $data['table'];
|
||||
$localSumday = $data['sumday'];
|
||||
$localBoot = $data['boot'];
|
||||
$localNumberTab = $data['number_tab'];
|
||||
$online_table_id = intval($localTable['online_table_id']);
|
||||
$onlineTable = Db::name('table')->where(array('id' => $online_table_id))->find();
|
||||
$game_id = intval($onlineTable['game_id']);
|
||||
if($game_id == 1){
|
||||
$bootTableName = 'boot';
|
||||
$numberTabTableName = 'number_tab';
|
||||
$betTableName = 'bet';
|
||||
}elseif($game_id == 2){
|
||||
$bootTableName = 'boot';
|
||||
$numberTabTableName = 'number_tab';
|
||||
$betTableName = 'bet';
|
||||
}else{
|
||||
return json(array('Success' => 0, 'Msg' => 'no_table_info'));
|
||||
}
|
||||
/*
|
||||
echo "<pre>";
|
||||
print_r($localTable);
|
||||
print_r($localSumday);
|
||||
print_r($localBoot);
|
||||
print_r($localNumberTab);
|
||||
echo "</pre>";
|
||||
exit();
|
||||
*/
|
||||
if($onlineTable && $onlineTable['table_token'] == $localTable['table_token']){
|
||||
foreach($localSumday AS $k => $v){
|
||||
$onlineSumday = Db::name('sumday')->where(array('table_id' => $online_table_id, 'day' => $v['day']))->find();
|
||||
if($onlineSumday){
|
||||
$lastOnlineSumdayID = $onlineSumday['id'];
|
||||
$localSumdayID = $v['id'];
|
||||
unset($v['id']);
|
||||
$v['table_id'] = $online_table_id;
|
||||
$v['table_name'] = $onlineTable['table_name'];
|
||||
Db::name('sumday')->where(array('id' => $onlineSumday['id']))->update($v);
|
||||
foreach($localBoot AS $key => $value){
|
||||
if($value['sumday_id'] == $localSumdayID){
|
||||
$boot = Db::name($bootTableName)->where(array('table_id' => $online_table_id, 'sumday_id' => $lastOnlineSumdayID, 'boot_num' => $value['boot_num']))->find();
|
||||
$localBootID = $value['id'];
|
||||
unset($value['id']);
|
||||
$value['table_id'] = $online_table_id;
|
||||
$value['table_name'] = $onlineTable['table_name'];
|
||||
$value['sumday_id'] = $lastOnlineSumdayID;
|
||||
if($boot){
|
||||
Db::name($bootTableName)->where(array('id' => $boot['id']))->limit(1)->update($value);
|
||||
foreach($localNumberTab AS $j => $z){
|
||||
if($z['boot_id'] == $localBootID){
|
||||
$numberTab = Db::name($numberTabTableName)->where(array('table_id' => $online_table_id, 'sumday_id' => $lastOnlineSumdayID, 'boot_id' => $boot['id'], 'number' => $z['number']))->find();
|
||||
unset($z['id']);
|
||||
unset($z['is_delete']);
|
||||
unset($z['is_edit']);
|
||||
if(isset($z['lucky_six'])){
|
||||
unset($z['lucky_six']);
|
||||
}
|
||||
if(isset($z['lucky_six_number'])){
|
||||
unset($z['lucky_six_number']);
|
||||
}
|
||||
unset($z['is_edit']);
|
||||
$z['table_id'] = $online_table_id;
|
||||
$z['table_name'] = $onlineTable['table_name'];
|
||||
$z['sumday_id'] = $lastOnlineSumdayID;
|
||||
$z['boot_id'] = $boot['id'];
|
||||
if($numberTab){
|
||||
Db::name($numberTabTableName)->where(array('id' => $numberTab['id']))->limit(1)->update($z);
|
||||
//var_dump($numberTab);
|
||||
//判断是否需要处理开结果
|
||||
if($game_id == 1){
|
||||
if($z['bet_status'] == 3 && ($numberTab['result'] != $z['result'] || $numberTab['pair'] != $z['pair'])){
|
||||
if($onlineTable['mode'] == 2){
|
||||
$this->do_opening_baccarat_win6($numberTab,$z);
|
||||
}else{
|
||||
$this->do_opening_baccarat($numberTab,$z);
|
||||
}
|
||||
}
|
||||
}elseif($game_id == 2){
|
||||
if($z['bet_status'] == 3 && $numberTab['result'] != $z['result']){
|
||||
$this->do_opening_dt($numberTab,$z);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$insertNumberTabID = Db::name($numberTabTableName)->insertGetId($z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$insertBootID = Db::name($bootTableName)->insertGetId($value);
|
||||
foreach($localNumberTab AS $j => $z){
|
||||
if($z['boot_id'] == $localBootID){
|
||||
unset($z['id']);
|
||||
unset($z['is_delete']);
|
||||
unset($z['is_edit']);
|
||||
if(isset($z['lucky_six'])){
|
||||
unset($z['lucky_six']);
|
||||
}
|
||||
if(isset($z['lucky_six_number'])){
|
||||
unset($z['lucky_six_number']);
|
||||
}
|
||||
$z['table_id'] = $online_table_id;
|
||||
$z['table_name'] = $onlineTable['table_name'];
|
||||
$z['sumday_id'] = $lastOnlineSumdayID;
|
||||
$z['boot_id'] = $insertBootID;
|
||||
$insertNumberTabID = Db::name($numberTabTableName)->insertGetId($z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$localSumdayID = $v['id'];
|
||||
unset($v['id']);
|
||||
$v['table_id'] = $online_table_id;
|
||||
$v['table_name'] = $onlineTable['table_name'];
|
||||
$insertSumdayID = Db::name('sumday')->insertGetId($v);
|
||||
foreach($localBoot AS $key => $value){
|
||||
if($value['sumday_id'] == $localSumdayID){
|
||||
$localBootID = $value['id'];
|
||||
unset($value['id']);
|
||||
$value['table_id'] = $online_table_id;
|
||||
$value['table_name'] = $onlineTable['table_name'];
|
||||
$value['sumday_id'] = $insertSumdayID;
|
||||
$insertBootID = Db::name($bootTableName)->insertGetId($value);
|
||||
foreach($localNumberTab AS $j => $z){
|
||||
if($z['boot_id'] == $localBootID){
|
||||
unset($z['id']);
|
||||
unset($z['is_delete']);
|
||||
unset($z['is_edit']);
|
||||
if(isset($z['lucky_six'])){
|
||||
unset($z['lucky_six']);
|
||||
}
|
||||
if(isset($z['lucky_six_number'])){
|
||||
unset($z['lucky_six_number']);
|
||||
}
|
||||
$z['table_id'] = $online_table_id;
|
||||
$z['table_name'] = $onlineTable['table_name'];
|
||||
$z['sumday_id'] = $insertSumdayID;
|
||||
$z['boot_id'] = $insertBootID;
|
||||
$insertNumberTabID = Db::name($numberTabTableName)->insertGetId($z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return json(array('Success' => 1, 'Msg' => 'sync_success'));
|
||||
}else{
|
||||
return json(array('Success' => 0, 'Msg' => 'no_table_info'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+554
@@ -0,0 +1,554 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use \think\Controller;
|
||||
use \think\Request;
|
||||
use \think\Db;
|
||||
use \think\Lang;
|
||||
use \think\Session;
|
||||
use \think\Log;
|
||||
|
||||
class Betinfo extends Controller{
|
||||
// 下注细分 百家乐
|
||||
public function betDetailBaccarat($flag,$v,$number_info,$user_info){
|
||||
if($flag == 1){
|
||||
$price = $user_info['price_banker'];
|
||||
$betType = '庄';
|
||||
$amountColumn = 'banker_amount';
|
||||
}elseif($flag == 2){
|
||||
$price = $user_info['price_player'];
|
||||
$betType = '闲';
|
||||
$amountColumn = 'player_amount';
|
||||
}elseif($flag == 3){
|
||||
$price = $user_info['price_tie_baccarat'];
|
||||
$betType = '和';
|
||||
$amountColumn = 'tie_amount';
|
||||
} elseif($flag == 4){
|
||||
$price = $user_info['price_pair'];
|
||||
$betType = '庄对';
|
||||
$amountColumn = 'banker_pair_amount';
|
||||
} elseif($flag == 5){
|
||||
$price = $user_info['price_pair'];
|
||||
$betType = '闲对';
|
||||
$amountColumn = 'player_pair_amount';
|
||||
}else{
|
||||
return $v;
|
||||
}
|
||||
|
||||
// 下注细分重组
|
||||
if($v[$amountColumn] > 0){
|
||||
$v[$amountColumn] = intval($v[$amountColumn]);
|
||||
$v['bet_type'] = $betType;
|
||||
$v['bet_amount'] = $v[$amountColumn];
|
||||
$v['bet_amount_all'] = $v[$amountColumn];
|
||||
if($number_info['bet_status'] == 3){
|
||||
if($flag >= 1 && $flag <= 3 && $v['result'] == $flag){
|
||||
$v['win'] = round($v[$amountColumn] * $price,2);
|
||||
}elseif($flag >= 4 && $flag <= 5 && $v['pair'] == $flag){
|
||||
$v['win'] = round($v[$amountColumn] * $price,2);
|
||||
}else{
|
||||
$v['win'] = to_number(round($v[$amountColumn],2));
|
||||
}
|
||||
}else{
|
||||
$v['win'] = 0;
|
||||
}
|
||||
return $v;
|
||||
}
|
||||
}
|
||||
// 下注细分 龙虎
|
||||
public function betDetailDt($flag,$v,$number_info,$user_info){
|
||||
if($flag == 1){
|
||||
$price = $user_info['price_banker'];
|
||||
$betType = '庄';
|
||||
$amountColumn = 'banker_amount';
|
||||
}elseif($flag == 2){
|
||||
$price = $user_info['price_player'];
|
||||
$betType = '闲';
|
||||
$amountColumn = 'player_amount';
|
||||
}elseif($flag == 3){
|
||||
$price = $user_info['price_tie_dt'];
|
||||
$betType = '和';
|
||||
$amountColumn = 'tie_amount';
|
||||
}else{
|
||||
return $v;
|
||||
}
|
||||
|
||||
// 下注细分重组
|
||||
if($v[$amountColumn] > 0){
|
||||
$v[$amountColumn] = intval($v[$amountColumn]);
|
||||
$v['bet_type'] = $betType;
|
||||
$v['bet_amount'] = $v[$amountColumn];
|
||||
$v['bet_amount_all'] = $v[$amountColumn];
|
||||
if($number_info['bet_status'] == 3){
|
||||
if($flag >= 1 && $flag <= 3 && $v['result'] == $flag){
|
||||
$v['win'] = round($v[$amountColumn] * $price,2);
|
||||
}else{
|
||||
$v['win'] = to_number(round($v[$amountColumn],2));
|
||||
}
|
||||
}else{
|
||||
$v['win'] = 0;
|
||||
}
|
||||
return $v;
|
||||
}
|
||||
}
|
||||
// 牛牛翻倍赔率判断
|
||||
public function getPrice($isWin,$num,$number_info,$user_info){
|
||||
if($isWin == 1){
|
||||
$winPoint = $number_info['result_player_'.$num];
|
||||
}else{
|
||||
$winPoint = $number_info['result_banker'];
|
||||
}
|
||||
if($winPoint >= 7 && $winPoint <= 9){
|
||||
$price = $user_info['price_n7_n9'];
|
||||
}elseif($winPoint == 10){
|
||||
$price = $user_info['price_nn'];
|
||||
}elseif($winPoint == 11){
|
||||
$price = $user_info['price_5n'];
|
||||
}elseif($winPoint == 12){
|
||||
$price = $user_info['price_bomb'];
|
||||
}else{
|
||||
$price = 1;
|
||||
}
|
||||
return $price;
|
||||
}
|
||||
// 下注细分 牛牛
|
||||
public function betDetailNn($flag,$v,$number_info,$user_info,$card_info){
|
||||
if($flag == 1){
|
||||
$result = '闲1';
|
||||
$price = 1;
|
||||
$betType = '闲1';
|
||||
$amountColumn = 'amount_player_1';
|
||||
$resultColumn = 'result_player_1';
|
||||
$winColumn = 'win_player_1';
|
||||
}elseif($flag == 2){
|
||||
$result = '闲1';
|
||||
$price = $this->getPrice($number_info['win_player_1'],1,$number_info,$user_info);
|
||||
$betType = '闲1翻倍';
|
||||
$amountColumn = 'amount_player_1_times';
|
||||
$resultColumn = 'result_player_1';
|
||||
$withholdColumn = 'withhold_player_1_times';
|
||||
$winColumn = 'win_player_1';
|
||||
}elseif($flag == 3){
|
||||
$result = '闲1';
|
||||
$price = 1;
|
||||
$betType = '庄(闲1)';
|
||||
$amountColumn = 'amount_player_1_banker';
|
||||
$resultColumn = 'result_player_1';
|
||||
$winColumn = 'win_player_1';
|
||||
}elseif($flag == 4){
|
||||
$result = '闲1';
|
||||
$price = $this->getPrice($number_info['win_player_1'],1,$number_info,$user_info);
|
||||
$betType = '庄(闲1)翻倍';
|
||||
$amountColumn = 'amount_player_1_banker_times';
|
||||
$resultColumn = 'result_player_1';
|
||||
$withholdColumn = 'withhold_player_1_banker_times';
|
||||
$winColumn = 'win_player_1';
|
||||
}elseif($flag == 5){
|
||||
$result = '闲2';
|
||||
$price = 1;
|
||||
$betType = '闲2';
|
||||
$amountColumn = 'amount_player_2';
|
||||
$resultColumn = 'result_player_2';
|
||||
$winColumn = 'win_player_2';
|
||||
}elseif($flag == 6){
|
||||
$result = '闲2';
|
||||
$price = $this->getPrice($number_info['win_player_2'],2,$number_info,$user_info);
|
||||
$betType = '闲2翻倍';
|
||||
$amountColumn = 'amount_player_2_times';
|
||||
$resultColumn = 'result_player_2';
|
||||
$withholdColumn = 'withhold_player_2_times';
|
||||
$winColumn = 'win_player_2';
|
||||
}elseif($flag == 7){
|
||||
$result = '闲2';
|
||||
$price = 1;
|
||||
$betType = '庄(闲2)';
|
||||
$amountColumn = 'amount_player_2_banker';
|
||||
$resultColumn = 'result_player_2';
|
||||
$winColumn = 'win_player_2';
|
||||
}elseif($flag == 8){
|
||||
$result = '闲2';
|
||||
$price = $this->getPrice($number_info['win_player_2'],2,$number_info,$user_info);
|
||||
$betType = '庄(闲2)翻倍';
|
||||
$amountColumn = 'amount_player_2_banker_times';
|
||||
$resultColumn = 'result_player_2';
|
||||
$withholdColumn = 'withhold_player_2_banker_times';
|
||||
$winColumn = 'win_player_2';
|
||||
}elseif($flag == 9){
|
||||
$result = '闲3';
|
||||
$price = 1;
|
||||
$betType = '闲3';
|
||||
$amountColumn = 'amount_player_3';
|
||||
$resultColumn = 'result_player_3';
|
||||
$winColumn = 'win_player_3';
|
||||
}elseif($flag == 10){
|
||||
$result = '闲3';
|
||||
$price = $this->getPrice($number_info['win_player_3'],3,$number_info,$user_info);
|
||||
$betType = '闲3翻倍';
|
||||
$amountColumn = 'amount_player_3_times';
|
||||
$resultColumn = 'result_player_3';
|
||||
$withholdColumn = 'withhold_player_3_times';
|
||||
$winColumn = 'win_player_3';
|
||||
}elseif($flag == 11){
|
||||
$result = '闲3';
|
||||
$price = 1;
|
||||
$betType = '庄(闲3)';
|
||||
$amountColumn = 'amount_player_3_banker';
|
||||
$resultColumn = 'result_player_3';
|
||||
$winColumn = 'win_player_3';
|
||||
}elseif($flag == 12){
|
||||
$result = '闲3';
|
||||
$price = $this->getPrice($number_info['win_player_3'],3,$number_info,$user_info);
|
||||
$betType = '庄(闲3)翻倍';
|
||||
$amountColumn = 'amount_player_3_banker_times';
|
||||
$resultColumn = 'result_player_3';
|
||||
$withholdColumn = 'withhold_player_3_banker_times';
|
||||
$winColumn = 'win_player_3';
|
||||
}else{
|
||||
return $v;
|
||||
}
|
||||
|
||||
// 下注细分重组
|
||||
if($v[$amountColumn] > 0){
|
||||
$v[$amountColumn] = intval($v[$amountColumn]);
|
||||
if($card_info && $card_info['status'] == 2){
|
||||
$v['card_result'] = '';
|
||||
$v['card_result'] .= '庄:'.interchange_nn($number_info['result_banker']).' '.$result.':'.interchange_nn($number_info[$resultColumn]).' ';
|
||||
if($number_info[$winColumn] == 1 ){
|
||||
$v['card_result'] .= $result.'赢';
|
||||
}else{
|
||||
$v['card_result'] .= '庄赢';
|
||||
}
|
||||
}else{
|
||||
$v['card_result'] = '';
|
||||
}
|
||||
$v['bet_type'] = $betType;
|
||||
$v['bet_amount'] = $v[$amountColumn];
|
||||
if($flag % 2 == 0){
|
||||
$v['bet_amount_all'] = $v[$amountColumn] + intval($v[$withholdColumn]);
|
||||
}else{
|
||||
$v['bet_amount_all'] = $v[$amountColumn];
|
||||
}
|
||||
if($number_info['bet_status'] == 3){
|
||||
if($number_info[$winColumn] == 1){
|
||||
$v['win'] = round($v[$amountColumn] * $price * 0.95, 2);
|
||||
}else{
|
||||
$v['win'] = to_number(round($v[$amountColumn] * $price,2));
|
||||
}
|
||||
}else{
|
||||
$v['win'] = 0;
|
||||
}
|
||||
|
||||
return $v;
|
||||
}
|
||||
}
|
||||
public function record(){
|
||||
// 用于分页和搜索查询的数据
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get',$get);
|
||||
$this->assign('query',$query);
|
||||
// 获取验证信息
|
||||
$token = Request::instance()->get('token');
|
||||
if($token != 'SGv9OOO4um53o9ZTW90AK0lk3rGaEq8FyANMiqlLSZymnOCfI76yHRGeJibvHwmgwieegkggyvh1Vs1jpQg9dAVsE7bipEiJ0By'){
|
||||
echo '非法操作';
|
||||
die;
|
||||
}
|
||||
$user_id = Request::instance()->get('user_id');
|
||||
if($user_id <= 0) {
|
||||
echo '用户ID错误';
|
||||
die;
|
||||
}
|
||||
$user_info = Db::name('user')->where('id',$user_id)->find();
|
||||
if(!$user_info){
|
||||
echo '用户不存在';
|
||||
die;
|
||||
}
|
||||
// 接收参数
|
||||
$game_id = Request::instance()->get('game_id');
|
||||
$startDate = Request::instance()->get('startDate');
|
||||
$endDate = Request::instance()->get('endDate');
|
||||
|
||||
// 查询日期处理
|
||||
if($startDate){
|
||||
$startTime = strtotime($startDate);
|
||||
}else{
|
||||
$startTime = strtotime(date('Y-m-d'),time());
|
||||
$get['startDate'] = date('Y-m-d',time());
|
||||
$this->assign('get',$get);
|
||||
}
|
||||
if($endDate){
|
||||
$endTime = strtotime($endDate) + 24*60*60 - 1;
|
||||
}else{
|
||||
$endTime = time();
|
||||
$get['endDate'] = date('Y-m-d',time());
|
||||
$this->assign('get',$get);
|
||||
}
|
||||
|
||||
// 查询数据条件
|
||||
$betWhere = array();
|
||||
$betWhere['create_time'] = array('between',[$startTime,$endTime]);
|
||||
$betWhere['user_id'] = $user_info['id'];
|
||||
if($game_id == 1 || $game_id == 2 || $game_id == 4){
|
||||
$betWhere['game_id'] = $game_id;
|
||||
}else{
|
||||
$betWhere['game_id'] = 1;
|
||||
$game_id = 1;
|
||||
$get['game_id'] = 1;
|
||||
$this->assign('get',$get);
|
||||
}
|
||||
// 查询注单信息
|
||||
if($game_id == 1){
|
||||
$bet = Db::name('bet')->where($betWhere)->order('id desc')->select();
|
||||
$betAmount = Db::name('bet')->where($betWhere)->sum('amount');
|
||||
$allAmount = Db::name('bet')->where($betWhere)->sum('amount');
|
||||
$allWinTotal = Db::name('bet')->where($betWhere)->sum('win_total');
|
||||
}elseif($game_id == 2){
|
||||
$bet = Db::name('bet_dt')->where($betWhere)->order('id desc')->select();
|
||||
$betAmount = Db::name('bet_dt')->where($betWhere)->sum('amount');
|
||||
$allAmount = Db::name('bet_dt')->where($betWhere)->sum('amount');
|
||||
$allWinTotal = Db::name('bet_dt')->where($betWhere)->sum('win_total');
|
||||
}elseif($game_id == 4){
|
||||
$bet = Db::name('bet_nn')->where($betWhere)->order('id desc')->select();
|
||||
// 下注金额
|
||||
$betAmount = Db::name('bet_nn')->where($betWhere)->sum('amount');
|
||||
// 扣除的金额( 包含预扣 )
|
||||
$allAmount = Db::name('bet_nn')->where($betWhere)->sum('amount');
|
||||
$allAmount += Db::name('bet_nn')->where($betWhere)->sum('withhold_player_1_times');
|
||||
$allAmount += Db::name('bet_nn')->where($betWhere)->sum('withhold_player_1_banker_times');
|
||||
$allAmount += Db::name('bet_nn')->where($betWhere)->sum('withhold_player_2_times');
|
||||
$allAmount += Db::name('bet_nn')->where($betWhere)->sum('withhold_player_2_banker_times');
|
||||
$allAmount += Db::name('bet_nn')->where($betWhere)->sum('withhold_player_3_times');
|
||||
$allAmount += Db::name('bet_nn')->where($betWhere)->sum('withhold_player_3_banker_times');
|
||||
// 总赢
|
||||
$allWinTotal = Db::name('bet_nn')->where($betWhere)->sum('win_total');
|
||||
}else{
|
||||
echo '游戏类型错误!';die;
|
||||
}
|
||||
// 组装注单信息
|
||||
$newBet = array();
|
||||
foreach($bet AS $k => $v){
|
||||
$v['create_time'] = date('Y-m-d',$v['create_time']);
|
||||
$v['game_nume'] = $v['game_id'].'-'.$v['boot_num'].'-'.$v['number'];
|
||||
|
||||
if($game_id == 1){
|
||||
$number_info = Db::name('number_tab')->where('id',$v['number_tab_id'])->find();
|
||||
if($number_info['bet_status'] == 3){
|
||||
if($v['result'] == 1){
|
||||
$result = '庄赢';
|
||||
}elseif($v['result'] == 2){
|
||||
$result = '闲赢';
|
||||
}elseif($v['result'] == 3){
|
||||
$result = '和';
|
||||
}else{
|
||||
$result = '-';
|
||||
}
|
||||
if($v['pair'] == 1){
|
||||
$pair = ',庄对';
|
||||
}elseif($v['pair'] == 2){
|
||||
$pair = ',闲对';
|
||||
}elseif($v['pair'] == 3){
|
||||
$pair = ',庄闲对';
|
||||
}else{
|
||||
$pair = '';
|
||||
}
|
||||
$v['card_result'] = $result.$pair;
|
||||
}else{
|
||||
$v['card_result'] = '-';
|
||||
}
|
||||
// 下注金额细分
|
||||
for($i=1; $i<=5; $i++){
|
||||
$result = $this->betDetailBaccarat($i,$v,$number_info,$user_info);
|
||||
if($result){
|
||||
$newBet[] = $result;
|
||||
}
|
||||
}
|
||||
}elseif($game_id == 2){
|
||||
$number_info = Db::name('number_tab')->where('id',$v['number_tab_id'])->find();
|
||||
if($number_info['bet_status'] == 3){
|
||||
if($v['result'] == 1){
|
||||
$result = '龙赢';
|
||||
}elseif($v['result'] == 2){
|
||||
$result = '虎赢';
|
||||
}elseif($v['result'] == 3){
|
||||
$result = '和';
|
||||
}
|
||||
$v['card_result'] = $result;
|
||||
}else{
|
||||
$v['card_result'] = '';
|
||||
}
|
||||
|
||||
// 下注金额细分
|
||||
for($i=1; $i<=3; $i++){
|
||||
$result = $this->betDetailDt($i,$v,$number_info,$user_info);
|
||||
if($result){
|
||||
$newBet[] = $result;
|
||||
}
|
||||
}
|
||||
|
||||
}elseif($game_id == 4){
|
||||
$card_info = Db::name('card_nn')->where('number_tab_id',$v['number_tab_id'])->find();
|
||||
$number_info = Db::name('number_tab')->where('id',$v['number_tab_id'])->find();
|
||||
|
||||
// 下注金额细分
|
||||
for($i=1; $i<=12; $i++){
|
||||
$result = $this->betDetailNn($i,$v,$number_info,$user_info,$card_info);
|
||||
if($result){
|
||||
$newBet[] = $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 重新赋值
|
||||
$bet = $newBet;
|
||||
// 渲染参数和模板
|
||||
$this->assign('bet',$bet);
|
||||
$this->assign('betAmount',$betAmount);
|
||||
$this->assign('allAmount',$allAmount);
|
||||
$this->assign('allWinTotal',$allWinTotal);
|
||||
$this->assign('user_info',$user_info);
|
||||
return $this->fetch();
|
||||
}
|
||||
// 下注记录(ajax刷新)
|
||||
public function recordAjax(){
|
||||
// 登录信息
|
||||
$user_id = Request::instance()->post('user_id');
|
||||
$user_info = Db::name('user')->where('id',$user_id)->find();
|
||||
|
||||
// 接收参数
|
||||
$game_id = Request::instance()->post('game_id');
|
||||
$startDate = Request::instance()->post('startDate');
|
||||
$endDate = Request::instance()->post('endDate');
|
||||
|
||||
// 查询日期处理
|
||||
if($startDate){
|
||||
$startTime = strtotime($startDate);
|
||||
}else{
|
||||
$startTime = strtotime(date('Y-m-d'),time());
|
||||
}
|
||||
if($endDate){
|
||||
$endTime = strtotime($endDate) + 24*60*60 - 1;
|
||||
}else{
|
||||
$endTime = time();
|
||||
}
|
||||
|
||||
// 查询数据条件
|
||||
$betWhere = array();
|
||||
$betWhere['create_time'] = array('between',[$startTime,$endTime]);
|
||||
$betWhere['user_id'] = $user_info['id'];
|
||||
if($game_id == 1 || $game_id == 2 || $game_id == 4){
|
||||
$betWhere['game_id'] = $game_id;
|
||||
}else{
|
||||
$betWhere['game_id'] = 1;
|
||||
$game_id = 1;
|
||||
$get['game_id'] = 1;
|
||||
$this->assign('get',$get);
|
||||
}
|
||||
// 查询注单信息
|
||||
if($game_id == 1){
|
||||
$bet = Db::name('bet')->where($betWhere)->order('id desc')->select();
|
||||
$betAmount = Db::name('bet')->where($betWhere)->sum('amount');
|
||||
$allAmount = Db::name('bet')->where($betWhere)->sum('amount');
|
||||
$allWinTotal = Db::name('bet')->where($betWhere)->sum('win_total');
|
||||
}elseif($game_id == 2){
|
||||
$bet = Db::name('bet_dt')->where($betWhere)->order('id desc')->select();
|
||||
$betAmount = Db::name('bet_dt')->where($betWhere)->sum('amount');
|
||||
$allAmount = Db::name('bet_dt')->where($betWhere)->sum('amount');
|
||||
$allWinTotal = Db::name('bet_dt')->where($betWhere)->sum('win_total');
|
||||
}elseif($game_id == 4){
|
||||
$bet = Db::name('bet_nn')->where($betWhere)->order('id desc')->select();
|
||||
// 下注金额
|
||||
$betAmount = Db::name('bet_nn')->where($betWhere)->sum('amount');
|
||||
// 扣除的金额( 包含预扣 )
|
||||
$allAmount = Db::name('bet_nn')->where($betWhere)->sum('amount');
|
||||
$allAmount += Db::name('bet_nn')->where($betWhere)->sum('withhold_player_1_times');
|
||||
$allAmount += Db::name('bet_nn')->where($betWhere)->sum('withhold_player_1_banker_times');
|
||||
$allAmount += Db::name('bet_nn')->where($betWhere)->sum('withhold_player_2_times');
|
||||
$allAmount += Db::name('bet_nn')->where($betWhere)->sum('withhold_player_2_banker_times');
|
||||
$allAmount += Db::name('bet_nn')->where($betWhere)->sum('withhold_player_3_times');
|
||||
$allAmount += Db::name('bet_nn')->where($betWhere)->sum('withhold_player_3_banker_times');
|
||||
// 总赢
|
||||
$allWinTotal = Db::name('bet_nn')->where($betWhere)->sum('win_total');
|
||||
}else{
|
||||
echo '游戏类型错误!';die;
|
||||
}
|
||||
// 组装注单信息
|
||||
$newBet = array();
|
||||
foreach($bet AS $k => $v){
|
||||
$v['create_time'] = date('Y-m-d',$v['create_time']);
|
||||
$v['game_nume'] = $v['game_id'].'-'.$v['boot_num'].'-'.$v['number'];
|
||||
|
||||
if($game_id == 1){
|
||||
$number_info = Db::name('number_tab')->where('id',$v['number_tab_id'])->find();
|
||||
if($number_info['bet_status'] == 3){
|
||||
if($v['result'] == 1){
|
||||
$result = '庄赢';
|
||||
}elseif($v['result'] == 2){
|
||||
$result = '闲赢';
|
||||
}elseif($v['result'] == 3){
|
||||
$result = '和';
|
||||
}else{
|
||||
$result = '-';
|
||||
}
|
||||
if($v['pair'] == 1){
|
||||
$pair = ',庄对';
|
||||
}elseif($v['pair'] == 2){
|
||||
$pair = ',闲对';
|
||||
}elseif($v['pair'] == 3){
|
||||
$pair = ',庄闲对';
|
||||
}else{
|
||||
$pair = '';
|
||||
}
|
||||
$v['card_result'] = $result.$pair;
|
||||
}else{
|
||||
$v['card_result'] = '-';
|
||||
}
|
||||
|
||||
// 下注金额细分
|
||||
for($i=1; $i<=5; $i++){
|
||||
$result = $this->betDetailBaccarat($i,$v,$number_info,$user_info);
|
||||
if($result){
|
||||
$newBet[] = $result;
|
||||
}
|
||||
}
|
||||
}elseif($game_id == 2){
|
||||
$number_info = Db::name('number_tab')->where('id',$v['number_tab_id'])->find();
|
||||
if($number_info['bet_status'] == 3){
|
||||
if($v['result'] == 1){
|
||||
$result = '龙赢';
|
||||
}elseif($v['result'] == 2){
|
||||
$result = '虎赢';
|
||||
}elseif($v['result'] == 3){
|
||||
$result = '和';
|
||||
}
|
||||
$v['card_result'] = $result;
|
||||
}else{
|
||||
$v['card_result'] = '';
|
||||
}
|
||||
|
||||
// 下注金额细分
|
||||
for($i=1; $i<=3; $i++){
|
||||
$result = $this->betDetailDt($i,$v,$number_info,$user_info);
|
||||
if($result){
|
||||
$newBet[] = $result;
|
||||
}
|
||||
}
|
||||
|
||||
}elseif($game_id == 4){
|
||||
$card_info = Db::name('card_nn')->where('number_tab_id',$v['number_tab_id'])->find();
|
||||
$number_info = Db::name('number_tab_nn')->where('id',$v['number_tab_id'])->find();
|
||||
|
||||
// 下注金额细分
|
||||
for($i=1; $i<=12; $i++){
|
||||
$result = $this->betDetailNn($i,$v,$number_info,$user_info,$card_info);
|
||||
if($result){
|
||||
$newBet[] = $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 重新赋值
|
||||
$bet = $newBet;
|
||||
// 返回数据
|
||||
return ['code'=>1,'bet'=>$bet,'betAmount'=>$betAmount,'allAmount'=>$allAmount,'allWinTotal'=>$allWinTotal];
|
||||
}
|
||||
}
|
||||
Executable
+463
@@ -0,0 +1,463 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\Db;
|
||||
use think\Request;
|
||||
use think\Session;
|
||||
|
||||
/**
|
||||
* 客服管理控制器
|
||||
* Class Chat
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class Chat extends Common
|
||||
{
|
||||
/**
|
||||
* 客服工作台
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$user_info = Session::get('user_info');
|
||||
$admin_id = $user_info['id'];
|
||||
|
||||
// 从数据库获取最新的login_token(避免session中没有的情况)
|
||||
$admin = Db::name('admin')->where('id', $admin_id)->field('login_token')->find();
|
||||
$login_token = $admin['login_token'] ?? '';
|
||||
|
||||
// 如果没有login_token,生成一个新的
|
||||
if (empty($login_token)) {
|
||||
$login_token = md5($admin_id . time() . uniqid());
|
||||
Db::name('admin')->where('id', $admin_id)->update(['login_token' => $login_token]);
|
||||
}
|
||||
|
||||
// 获取客服配置
|
||||
$admin_status = Db::name('chat_admin_status')->where('admin_id', $admin_id)->find();
|
||||
if (!$admin_status) {
|
||||
// 创建默认配置
|
||||
Db::name('chat_admin_status')->insert([
|
||||
'admin_id' => $admin_id,
|
||||
'max_sessions' => 10,
|
||||
'is_enabled' => 1,
|
||||
'create_time' => time(),
|
||||
'update_time' => time(),
|
||||
]);
|
||||
$admin_status = ['max_sessions' => 10, 'is_enabled' => 1];
|
||||
}
|
||||
|
||||
$this->assign('admin_status', $admin_status);
|
||||
$this->assign('admin_id', $admin_id);
|
||||
$this->assign('login_token', $login_token);
|
||||
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会话列表 (AJAX)
|
||||
*/
|
||||
public function sessions()
|
||||
{
|
||||
$user_info = Session::get('user_info');
|
||||
$admin_id = $user_info['id'];
|
||||
$status = Request::instance()->get('status', 1); // 默认进行中
|
||||
|
||||
$where = ['admin_id' => $admin_id];
|
||||
if ($status !== 'all') {
|
||||
$where['status'] = (int)$status;
|
||||
}
|
||||
|
||||
$sessions = Db::name('chat_session')
|
||||
->where($where)
|
||||
->order('last_msg_time desc, create_time desc')
|
||||
->select();
|
||||
|
||||
foreach ($sessions as &$session) {
|
||||
// 获取用户信息
|
||||
$user = Db::name('user')->where('id', $session['user_id'])->find();
|
||||
$session['user_info'] = [
|
||||
'username' => $user['username'] ?? '',
|
||||
'nickname' => $user['nickname'] ?? $user['username'] ?? '',
|
||||
'money' => $user['money'] ?? 0,
|
||||
];
|
||||
|
||||
// 未读消息数
|
||||
$session['unread_count'] = Db::name('chat_message')
|
||||
->where('session_id', $session['id'])
|
||||
->where('sender_type', 1) // 用户发送
|
||||
->where('status', '<', 3) // 未读
|
||||
->count();
|
||||
|
||||
// 格式化时间
|
||||
$session['create_time_fmt'] = date('Y-m-d H:i:s', $session['create_time']);
|
||||
$session['last_msg_time_fmt'] = $session['last_msg_time'] ? date('H:i', $session['last_msg_time']) : '';
|
||||
|
||||
// 来源
|
||||
$sourceMap = [1 => 'PC', 2 => 'Game', 3 => 'Portal'];
|
||||
$session['source_name'] = $sourceMap[$session['source']] ?? 'Unknown';
|
||||
}
|
||||
|
||||
return json(['code' => 0, 'data' => $sessions]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取待分配会话列表 (AJAX)
|
||||
*/
|
||||
public function pending()
|
||||
{
|
||||
$sessions = Db::name('chat_session')
|
||||
->where('status', 0) // 待分配
|
||||
->order('create_time asc')
|
||||
->select();
|
||||
|
||||
foreach ($sessions as &$session) {
|
||||
$user = Db::name('user')->where('id', $session['user_id'])->find();
|
||||
$session['user_info'] = [
|
||||
'username' => $user['username'] ?? '',
|
||||
'nickname' => $user['nickname'] ?? $user['username'] ?? '',
|
||||
'money' => $user['money'] ?? 0,
|
||||
];
|
||||
$session['create_time_fmt'] = date('Y-m-d H:i:s', $session['create_time']);
|
||||
$sourceMap = [1 => 'PC', 2 => 'Game', 3 => 'Portal'];
|
||||
$session['source_name'] = $sourceMap[$session['source']] ?? 'Unknown';
|
||||
}
|
||||
|
||||
return json(['code' => 0, 'data' => $sessions]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取消息历史 (AJAX)
|
||||
*/
|
||||
public function messages()
|
||||
{
|
||||
$session_id = Request::instance()->get('session_id');
|
||||
$last_id = Request::instance()->get('last_id', 0);
|
||||
$limit = Request::instance()->get('limit', 50);
|
||||
|
||||
if (!$session_id) {
|
||||
return json(['code' => 1, 'msg' => '参数错误']);
|
||||
}
|
||||
|
||||
$query = Db::name('chat_message')->where('session_id', $session_id);
|
||||
if ($last_id > 0) {
|
||||
$query->where('id', '<', $last_id);
|
||||
}
|
||||
|
||||
$messages = $query->order('id desc')->limit($limit)->select();
|
||||
$messages = array_reverse($messages); // 按时间正序
|
||||
|
||||
foreach ($messages as &$msg) {
|
||||
$msg['create_time_fmt'] = date('H:i:s', $msg['create_time']);
|
||||
}
|
||||
|
||||
return json(['code' => 0, 'data' => $messages]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束会话 (AJAX)
|
||||
*/
|
||||
public function endSession()
|
||||
{
|
||||
$session_id = Request::instance()->post('session_id');
|
||||
$user_info = Session::get('user_info');
|
||||
|
||||
if (!$session_id) {
|
||||
return json(['code' => 1, 'msg' => '参数错误']);
|
||||
}
|
||||
|
||||
$session = Db::name('chat_session')->where('id', $session_id)->find();
|
||||
if (!$session || $session['admin_id'] != $user_info['id']) {
|
||||
return json(['code' => 1, 'msg' => '无权操作']);
|
||||
}
|
||||
|
||||
Db::name('chat_session')->where('id', $session_id)->update([
|
||||
'status' => 2,
|
||||
'end_time' => time(),
|
||||
'update_time' => time(),
|
||||
]);
|
||||
|
||||
insertAdminLog('结束客服会话', '会话ID: ' . $session_id);
|
||||
|
||||
return json(['code' => 0, 'msg' => '操作成功']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动接入会话 (AJAX)
|
||||
*/
|
||||
public function acceptSession()
|
||||
{
|
||||
$session_id = Request::instance()->post('session_id');
|
||||
$user_info = Session::get('user_info');
|
||||
$admin_id = $user_info['id'];
|
||||
|
||||
if (!$session_id) {
|
||||
return json(['code' => 1, 'msg' => '参数错误']);
|
||||
}
|
||||
|
||||
// 检查会话是否存在且状态为待分配
|
||||
$session = Db::name('chat_session')->where('id', $session_id)->find();
|
||||
if (!$session) {
|
||||
return json(['code' => 1, 'msg' => '会话不存在']);
|
||||
}
|
||||
if ($session['status'] != 0) {
|
||||
return json(['code' => 1, 'msg' => '该会话已被接入']);
|
||||
}
|
||||
|
||||
// 检查客服当前会话数是否已满
|
||||
$admin_status = Db::name('chat_admin_status')->where('admin_id', $admin_id)->find();
|
||||
$max_sessions = $admin_status['max_sessions'] ?? 10;
|
||||
$current_sessions = Db::name('chat_session')
|
||||
->where('admin_id', $admin_id)
|
||||
->where('status', 1)
|
||||
->count();
|
||||
|
||||
if ($current_sessions >= $max_sessions) {
|
||||
return json(['code' => 1, 'msg' => '已达最大会话数限制(' . $max_sessions . ')']);
|
||||
}
|
||||
|
||||
// 接入会话
|
||||
$result = Db::name('chat_session')->where('id', $session_id)->where('status', 0)->update([
|
||||
'admin_id' => $admin_id,
|
||||
'status' => 1,
|
||||
'update_time' => time(),
|
||||
]);
|
||||
|
||||
if ($result) {
|
||||
insertAdminLog('接入客服会话', '会话ID: ' . $session_id);
|
||||
return json(['code' => 0, 'msg' => '接入成功']);
|
||||
} else {
|
||||
return json(['code' => 1, 'msg' => '接入失败,可能已被其他客服接入']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转接会话 (AJAX)
|
||||
*/
|
||||
public function transfer()
|
||||
{
|
||||
$session_id = Request::instance()->post('session_id');
|
||||
$target_admin_id = Request::instance()->post('target_admin_id');
|
||||
$user_info = Session::get('user_info');
|
||||
|
||||
if (!$session_id || !$target_admin_id) {
|
||||
return json(['code' => 1, 'msg' => '参数错误']);
|
||||
}
|
||||
|
||||
$session = Db::name('chat_session')->where('id', $session_id)->find();
|
||||
if (!$session || $session['admin_id'] != $user_info['id']) {
|
||||
return json(['code' => 1, 'msg' => '无权操作']);
|
||||
}
|
||||
|
||||
Db::name('chat_session')->where('id', $session_id)->update([
|
||||
'admin_id' => $target_admin_id,
|
||||
'update_time' => time(),
|
||||
]);
|
||||
|
||||
insertAdminLog('转接客服会话', '会话ID: ' . $session_id . ', 转接给: ' . $target_admin_id);
|
||||
|
||||
return json(['code' => 0, 'msg' => '转接成功']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取在线客服列表 (AJAX)
|
||||
*/
|
||||
public function onlineAgents()
|
||||
{
|
||||
$user_info = Session::get('user_info');
|
||||
|
||||
// 获取启用客服功能的管理员
|
||||
$agents = Db::name('chat_admin_status')
|
||||
->alias('s')
|
||||
->join('admin a', 'a.id = s.admin_id')
|
||||
->where('s.is_enabled', 1)
|
||||
->where('a.id', '<>', $user_info['id'])
|
||||
->field('a.id, a.admin as username, a.admin as nickname, s.max_sessions')
|
||||
->select();
|
||||
|
||||
return json(['code' => 0, 'data' => $agents]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 聊天记录查询
|
||||
*/
|
||||
public function record()
|
||||
{
|
||||
$get = Request::instance()->get();
|
||||
$this->assign('get', $get);
|
||||
|
||||
$username = Request::instance()->get('username');
|
||||
$admin_id = Request::instance()->get('admin_id');
|
||||
$startDate = Request::instance()->get('startDate');
|
||||
$endDate = Request::instance()->get('endDate');
|
||||
$export = Request::instance()->get('export');
|
||||
|
||||
$where = [];
|
||||
$startTime = 0;
|
||||
$endTime = time();
|
||||
|
||||
if ($startDate) $startTime = strtotime($startDate);
|
||||
if ($endDate) $endTime = strtotime($endDate) + 86400;
|
||||
$where['s.create_time'] = ['between', [$startTime, $endTime]];
|
||||
|
||||
if ($admin_id) {
|
||||
$where['s.admin_id'] = $admin_id;
|
||||
}
|
||||
|
||||
$query = Db::name('chat_session')
|
||||
->alias('s')
|
||||
->join('user u', 'u.id = s.user_id', 'left')
|
||||
->join('admin a', 'a.id = s.admin_id', 'left')
|
||||
->where($where);
|
||||
|
||||
if ($username) {
|
||||
$query->where('u.username', 'like', "%{$username}%");
|
||||
}
|
||||
|
||||
if ($export == 1) {
|
||||
$list = $query->field('s.*, u.username, u.nickname as user_nickname, a.admin as admin_username')
|
||||
->order('s.create_time desc')
|
||||
->select();
|
||||
|
||||
$excelData = [];
|
||||
foreach ($list as $k => $v) {
|
||||
$excelData[$k][0] = $v['id'];
|
||||
$excelData[$k][1] = $v['username'];
|
||||
$excelData[$k][2] = $v['admin_username'] ?? '未分配';
|
||||
$excelData[$k][3] = ['PC', 'Game', 'Portal'][$v['source'] - 1] ?? '';
|
||||
$excelData[$k][4] = ['待分配', '进行中', '已结束'][$v['status']] ?? '';
|
||||
$excelData[$k][5] = $v['rating'] ?? '-';
|
||||
$excelData[$k][6] = date('Y-m-d H:i:s', $v['create_time']);
|
||||
$excelData[$k][7] = $v['end_time'] ? date('Y-m-d H:i:s', $v['end_time']) : '-';
|
||||
}
|
||||
$title = ['会话ID', '用户名', '客服', '来源', '状态', '评分', '开始时间', '结束时间'];
|
||||
$this->exportExcelCore($excelData, '聊天记录-' . date('Ymd'), $title);
|
||||
exit;
|
||||
}
|
||||
|
||||
$list = $query->field('s.*, u.username, u.nickname as user_nickname, a.admin as admin_username')
|
||||
->order('s.create_time desc')
|
||||
->paginate(15, false, ['query' => $get]);
|
||||
|
||||
// 获取客服列表
|
||||
$admins = Db::name('admin')->where('status', 1)->field('id, admin as username, admin as nickname')->select();
|
||||
|
||||
$this->assign('list', $list);
|
||||
$this->assign('admins', $admins);
|
||||
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看会话详情
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$session_id = Request::instance()->get('session_id');
|
||||
|
||||
$session = Db::name('chat_session')
|
||||
->alias('s')
|
||||
->join('user u', 'u.id = s.user_id', 'left')
|
||||
->join('admin a', 'a.id = s.admin_id', 'left')
|
||||
->where('s.id', $session_id)
|
||||
->field('s.*, u.username, u.nickname as user_nickname, u.money, a.admin as admin_username')
|
||||
->find();
|
||||
|
||||
if (!$session) {
|
||||
$this->error('会话不存在');
|
||||
}
|
||||
|
||||
$messages = Db::name('chat_message')
|
||||
->where('session_id', $session_id)
|
||||
->order('id asc')
|
||||
->select();
|
||||
|
||||
$this->assign('session', $session);
|
||||
$this->assign('messages', $messages);
|
||||
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 客服统计
|
||||
*/
|
||||
public function stats()
|
||||
{
|
||||
$user_info = Session::get('user_info');
|
||||
$admin_id = Request::instance()->get('admin_id', $user_info['id']);
|
||||
$startDate = Request::instance()->get('startDate', date('Y-m-d', strtotime('-7 days')));
|
||||
$endDate = Request::instance()->get('endDate', date('Y-m-d'));
|
||||
|
||||
$startTime = strtotime($startDate);
|
||||
$endTime = strtotime($endDate) + 86400;
|
||||
|
||||
$where = [
|
||||
'admin_id' => $admin_id,
|
||||
'create_time' => ['between', [$startTime, $endTime]],
|
||||
];
|
||||
|
||||
// 统计数据
|
||||
$stats = [
|
||||
'total_sessions' => Db::name('chat_session')->where($where)->count(),
|
||||
'ended_sessions' => Db::name('chat_session')->where($where)->where('status', 2)->count(),
|
||||
'avg_rating' => Db::name('chat_session')->where($where)->whereNotNull('rating')->avg('rating') ?: 0,
|
||||
'total_messages' => Db::name('chat_message')
|
||||
->alias('m')
|
||||
->join('chat_session s', 's.id = m.session_id')
|
||||
->where('s.admin_id', $admin_id)
|
||||
->where('m.create_time', 'between', [$startTime, $endTime])
|
||||
->count(),
|
||||
];
|
||||
|
||||
$this->assign('stats', $stats);
|
||||
$this->assign('startDate', $startDate);
|
||||
$this->assign('endDate', $endDate);
|
||||
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取快捷回复列表 (AJAX)
|
||||
*/
|
||||
public function quickReplies()
|
||||
{
|
||||
$category = Request::instance()->get('category');
|
||||
|
||||
$query = Db::name('chat_quick_reply')->where('status', 1);
|
||||
if ($category) {
|
||||
$query->where('category', $category);
|
||||
}
|
||||
|
||||
$list = $query->order('sort asc, id asc')->select();
|
||||
$categories = Db::name('chat_quick_reply')
|
||||
->where('status', 1)
|
||||
->whereNotNull('category')
|
||||
->where('category', '<>', '')
|
||||
->group('category')
|
||||
->column('category');
|
||||
|
||||
return json(['code' => 0, 'data' => $list, 'categories' => $categories]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 图片上传
|
||||
*/
|
||||
public function upload()
|
||||
{
|
||||
$file = Request::instance()->file('image');
|
||||
if (!$file) {
|
||||
return json(['code' => 1, 'msg' => '请选择文件']);
|
||||
}
|
||||
|
||||
// 验证文件
|
||||
$info = $file->validate([
|
||||
'size' => 2097152, // 2MB
|
||||
'ext' => 'jpg,png,gif,jpeg'
|
||||
])->move(ROOT_PATH . 'public/uploads/chat/' . date('Ymd'));
|
||||
|
||||
if ($info) {
|
||||
$url = '/uploads/chat/' . date('Ymd') . '/' . $info->getSaveName();
|
||||
return json(['code' => 0, 'url' => $url]);
|
||||
} else {
|
||||
return json(['code' => 1, 'msg' => $file->getError()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
+228
@@ -0,0 +1,228 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\Db;
|
||||
use think\Request;
|
||||
|
||||
/**
|
||||
* 快捷回复管理控制器
|
||||
* Class ChatQuickReply
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class ChatQuickReply extends Common
|
||||
{
|
||||
/**
|
||||
* 快捷回复列表
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$get = Request::instance()->get();
|
||||
$this->assign('get', $get);
|
||||
|
||||
$category = Request::instance()->get('category');
|
||||
$status = Request::instance()->get('status');
|
||||
|
||||
$where = [];
|
||||
if ($category) {
|
||||
$where['category'] = $category;
|
||||
}
|
||||
if ($status !== null && $status !== '') {
|
||||
$where['status'] = (int)$status;
|
||||
}
|
||||
|
||||
$list = Db::name('chat_quick_reply')
|
||||
->where($where)
|
||||
->order('sort asc, id desc')
|
||||
->paginate(15, false, ['query' => $get]);
|
||||
|
||||
// 获取分类列表
|
||||
$categories = Db::name('chat_quick_reply')
|
||||
->whereNotNull('category')
|
||||
->where('category', '<>', '')
|
||||
->group('category')
|
||||
->column('category');
|
||||
|
||||
$this->assign('list', $list);
|
||||
$this->assign('categories', $categories);
|
||||
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加快捷回复
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if (Request::instance()->isPost()) {
|
||||
$data = Request::instance()->post();
|
||||
|
||||
// 验证
|
||||
if (empty($data['title'])) {
|
||||
$this->error('标题不能为空');
|
||||
}
|
||||
if (empty($data['content'])) {
|
||||
$this->error('内容不能为空');
|
||||
}
|
||||
|
||||
$insertData = [
|
||||
'category' => $data['category'] ?? null,
|
||||
'title' => $data['title'],
|
||||
'content' => $data['content'],
|
||||
'sort' => (int)($data['sort'] ?? 0),
|
||||
'status' => (int)($data['status'] ?? 1),
|
||||
'create_time' => time(),
|
||||
'update_time' => time(),
|
||||
];
|
||||
|
||||
$result = Db::name('chat_quick_reply')->insert($insertData);
|
||||
|
||||
if ($result) {
|
||||
insertAdminLog('添加快捷回复', '标题: ' . $data['title']);
|
||||
$this->success('添加成功', '/chat_quick_reply/index');
|
||||
} else {
|
||||
$this->error('添加失败');
|
||||
}
|
||||
}
|
||||
|
||||
// 获取分类列表
|
||||
$categories = Db::name('chat_quick_reply')
|
||||
->whereNotNull('category')
|
||||
->where('category', '<>', '')
|
||||
->group('category')
|
||||
->column('category');
|
||||
|
||||
$this->assign('categories', $categories);
|
||||
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑快捷回复
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$id = Request::instance()->param('id');
|
||||
|
||||
if (Request::instance()->isPost()) {
|
||||
$data = Request::instance()->post();
|
||||
|
||||
// 验证
|
||||
if (empty($data['title'])) {
|
||||
$this->error('标题不能为空');
|
||||
}
|
||||
if (empty($data['content'])) {
|
||||
$this->error('内容不能为空');
|
||||
}
|
||||
|
||||
$updateData = [
|
||||
'category' => $data['category'] ?? null,
|
||||
'title' => $data['title'],
|
||||
'content' => $data['content'],
|
||||
'sort' => (int)($data['sort'] ?? 0),
|
||||
'status' => (int)($data['status'] ?? 1),
|
||||
'update_time' => time(),
|
||||
];
|
||||
|
||||
$result = Db::name('chat_quick_reply')->where('id', $id)->update($updateData);
|
||||
|
||||
if ($result !== false) {
|
||||
insertAdminLog('编辑快捷回复', 'ID: ' . $id);
|
||||
$this->success('修改成功', '/chat_quick_reply/index');
|
||||
} else {
|
||||
$this->error('修改失败');
|
||||
}
|
||||
}
|
||||
|
||||
$info = Db::name('chat_quick_reply')->where('id', $id)->find();
|
||||
if (!$info) {
|
||||
$this->error('记录不存在');
|
||||
}
|
||||
|
||||
// 获取分类列表
|
||||
$categories = Db::name('chat_quick_reply')
|
||||
->whereNotNull('category')
|
||||
->where('category', '<>', '')
|
||||
->group('category')
|
||||
->column('category');
|
||||
|
||||
$this->assign('info', $info);
|
||||
$this->assign('categories', $categories);
|
||||
|
||||
return $this->fetch('add');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除快捷回复
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
$id = Request::instance()->param('id');
|
||||
|
||||
if (!$id) {
|
||||
$this->error('参数错误');
|
||||
}
|
||||
|
||||
$info = Db::name('chat_quick_reply')->where('id', $id)->find();
|
||||
if (!$info) {
|
||||
$this->error('记录不存在');
|
||||
}
|
||||
|
||||
$result = Db::name('chat_quick_reply')->where('id', $id)->delete();
|
||||
|
||||
if ($result) {
|
||||
insertAdminLog('删除快捷回复', 'ID: ' . $id . ', 标题: ' . $info['title']);
|
||||
$this->success('删除成功');
|
||||
} else {
|
||||
$this->error('删除失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
*/
|
||||
public function status()
|
||||
{
|
||||
$id = Request::instance()->post('id');
|
||||
$status = Request::instance()->post('status');
|
||||
|
||||
if (!$id) {
|
||||
return json(['code' => 1, 'msg' => '参数错误']);
|
||||
}
|
||||
|
||||
$result = Db::name('chat_quick_reply')->where('id', $id)->update([
|
||||
'status' => (int)$status,
|
||||
'update_time' => time(),
|
||||
]);
|
||||
|
||||
if ($result !== false) {
|
||||
return json(['code' => 0, 'msg' => '操作成功']);
|
||||
} else {
|
||||
return json(['code' => 1, 'msg' => '操作失败']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改排序
|
||||
*/
|
||||
public function sort()
|
||||
{
|
||||
$id = Request::instance()->post('id');
|
||||
$sort = Request::instance()->post('sort');
|
||||
|
||||
if (!$id) {
|
||||
return json(['code' => 1, 'msg' => '参数错误']);
|
||||
}
|
||||
|
||||
$result = Db::name('chat_quick_reply')->where('id', $id)->update([
|
||||
'sort' => (int)$sort,
|
||||
'update_time' => time(),
|
||||
]);
|
||||
|
||||
if ($result !== false) {
|
||||
return json(['code' => 0, 'msg' => '操作成功']);
|
||||
} else {
|
||||
return json(['code' => 1, 'msg' => '操作失败']);
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+86
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\Controller;
|
||||
use think\Session;
|
||||
use think\Loader;
|
||||
use think\Request;
|
||||
|
||||
class Common extends Controller{
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$user_info = Session::get('user_info');
|
||||
$this->assign('user_info',$user_info);
|
||||
if(empty($user_info)){
|
||||
$this->redirect('/login/index',302);
|
||||
exit();
|
||||
}
|
||||
//角色判断
|
||||
$request= Request::instance();
|
||||
$curContrller = $request->controller();
|
||||
$curAction = $request->action();
|
||||
//监控角色可以访问的页面
|
||||
$jiankongController = array(
|
||||
'Index',
|
||||
'Waybill',
|
||||
'Game',
|
||||
'Memo',
|
||||
'Info',
|
||||
'Log',
|
||||
'Login',
|
||||
'Chat',
|
||||
'ChatQuickReply',
|
||||
);
|
||||
if($user_info['role'] == 1){
|
||||
if(!in_array($curContrller, $jiankongController)){
|
||||
die('您没有权限访问该页面');
|
||||
}
|
||||
}
|
||||
$dlController = array(
|
||||
'Info',
|
||||
'Index',
|
||||
'Agent',
|
||||
'Login',
|
||||
'Chat',
|
||||
'ChatQuickReply',
|
||||
);
|
||||
if($user_info['role'] == 2){
|
||||
if(!in_array($curContrller, $dlController)){
|
||||
die('您没有权限访问该页面');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*+----------------------------------------------------------
|
||||
* 输出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,244 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\Db;
|
||||
use think\Request;
|
||||
use think\Session;
|
||||
|
||||
class Controller extends Common{
|
||||
/**
|
||||
* 操作员列表
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 接收分页的条件
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get',$get);
|
||||
$this->assign('query',$query);
|
||||
|
||||
// 接收搜索的条件信息
|
||||
$nickname = Request::instance()->get('nickname');
|
||||
$start = Request::instance()->get('start');
|
||||
$end = Request::instance()->get('end');
|
||||
$startTime = 0;
|
||||
$endTime = time();
|
||||
|
||||
// 拼装搜索条件
|
||||
$where = array();
|
||||
if($nickname) $where['nickname'] = array('like',"%".$nickname."%");
|
||||
if($start) $startTime = strtotime($start);
|
||||
if($end) $endTime = strtotime($end);
|
||||
|
||||
// 获取所有操作员信息
|
||||
$user_list = Db::name('user_controller')->where($where)->paginate(10,false,array('query'=>$get));
|
||||
$user_sum = Db::name('user_controller')->where($where)->count();
|
||||
foreach($user_list as $k => $v){
|
||||
$table = Db::name('table')->find($v['table_id']);
|
||||
$v['table_name'] = $table['table_name'];
|
||||
if($v['last_login_time'] > 0) $v['last_login_time'] = date('Y-m-d H:i:s',$v['last_login_time']);
|
||||
if($v['last_login_time'] <= 0) $v['last_login_time'] = '尚未登录';
|
||||
if(empty($v['last_login_ip'])) $v['last_login_ip'] = '尚未登录';
|
||||
$user_list[$k] = $v;
|
||||
}
|
||||
|
||||
// 渲染变量和模板
|
||||
$this->assign('user_list',$user_list);
|
||||
$this->assign('user_sum',$user_sum);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加操作员页面
|
||||
*/
|
||||
public function controller_add()
|
||||
{
|
||||
// 查询所有桌子信息
|
||||
$table_list = Db::name('table')->select();
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('table_list',$table_list);
|
||||
return $this->fetch('/controller/controller-add');
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理添加操作员
|
||||
*/
|
||||
public function do_controller_add()
|
||||
{
|
||||
if(Request::instance()->post()){
|
||||
|
||||
// 接收提交过来的数据
|
||||
$username = Request::instance()->post('username');
|
||||
$nickname = Request::instance()->post('nickname');
|
||||
$pass = Request::instance()->post('pass');
|
||||
$repass = Request::instance()->post('repass');
|
||||
$table = Request::instance()->post('table');
|
||||
|
||||
// 数据验证
|
||||
if( !isset($table) && empty($table) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'请选择所属桌子!']));
|
||||
}
|
||||
if( !isset($username) && empty($username) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'用户名不能为空!']));
|
||||
}
|
||||
if( !isset($nickname) && empty($nickname) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'昵称不能为空!']));
|
||||
}
|
||||
if( !isset($pass) && empty($pass) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'密码不能为空!']));
|
||||
}
|
||||
if( !isset($repass) && empty($repass) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'确认密码不能为空!']));
|
||||
}
|
||||
if( $repass != $pass ){
|
||||
die(json_encode(['code'=>0,'msg'=>'两次密码不一致!']));
|
||||
}
|
||||
|
||||
// 检测用户名是否已经被注册
|
||||
$user = Db::name('user_controller')->where('username',$username)->find();
|
||||
if($user){
|
||||
die(json_encode(['code'=>0,'msg'=>'账号已存在!']));
|
||||
}
|
||||
|
||||
// 拼装数据
|
||||
$data = array();
|
||||
$data['username'] = $username;
|
||||
$data['nickname'] = $nickname;
|
||||
$data['password'] = think_ucenter_md5($pass, UC_AUTH_KEY);
|
||||
$data['table_id'] = $table;
|
||||
$data['is_delete'] = 0;
|
||||
$insert_id = Db::name('user_controller')->insertGetId($data);
|
||||
if($insert_id){
|
||||
insertAdminLog('添加操作员','添加操作员: | ID: '.$insert_id.' | 账号: '.$username);
|
||||
die(json_encode(['code'=>1,'msg'=>'添加成功!']));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'添加失败!']));
|
||||
}
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'操作错误!']));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑操作员页面
|
||||
*/
|
||||
public function controller_edit()
|
||||
{
|
||||
// 接收会员ID,查询会员信息
|
||||
$controller_id = Request::instance()->get('controller_id');
|
||||
$controller = Db::name('user_controller')->find($controller_id);
|
||||
|
||||
// 查询所有桌子信息
|
||||
$table_list = Db::name('table')->select();
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('table_list',$table_list);
|
||||
$this->assign('controller',$controller);
|
||||
return $this->fetch('/controller/controller-edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理修改操作员信息
|
||||
*/
|
||||
public function do_controller_edit()
|
||||
{
|
||||
if(Request::instance()->post()){
|
||||
// 接收传过来的数据
|
||||
$controller_id = Request::instance()->post('controller_id');
|
||||
$username = Request::instance()->post('username');
|
||||
$nickname = Request::instance()->post('nickname');
|
||||
$pass = Request::instance()->post('pass');
|
||||
$repass = Request::instance()->post('repass');
|
||||
$table = Request::instance()->post('table');
|
||||
|
||||
//数据验证
|
||||
if(empty($username)){
|
||||
die(json_encode(['code'=>0,'msg'=>'会员账号不能为空!']));
|
||||
}
|
||||
if(empty($nickname)){
|
||||
die(json_encode(['code'=>0,'msg'=>'会员昵称不能为空!']));
|
||||
}
|
||||
if(!empty($pass) && strlen($pass) < 6){
|
||||
die(json_encode(['code'=>0,'msg'=>'密码长度不能少于6位!']));
|
||||
}
|
||||
if(!empty($pass) && $pass != $repass){
|
||||
die(json_encode(['code'=>0,'msg'=>'两次密码输入不一致!']));
|
||||
}
|
||||
if(empty($table)){
|
||||
die(json_encode(['code'=>0,'msg'=>'请选择所属桌子!']));
|
||||
}
|
||||
|
||||
// 拼装数据
|
||||
$data = array();
|
||||
$data['username'] = $username;
|
||||
$data['nickname'] = $nickname;
|
||||
if(!empty($pass)) $data['password'] = think_ucenter_md5($pass, UC_AUTH_KEY);
|
||||
$data['table_id'] = $table;
|
||||
|
||||
// 修改操作员资料
|
||||
$result = Db::name('user_controller')->where('id',$controller_id)->update($data);
|
||||
if($result){
|
||||
insertAdminLog('修改操作员','修改操作员: | ID: '.$controller_id.' | 账号: '.$username);
|
||||
die(json_encode(['code'=>1,'msg'=>'修改成功!']));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'修改失败!']));
|
||||
}
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'操作错误!']));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除操作员
|
||||
*/
|
||||
public function controller_del()
|
||||
{
|
||||
if(Request::instance()->post()){
|
||||
// 接收数据
|
||||
$controller_id = Request::instance()->post('controller_id');
|
||||
|
||||
// 数据验证
|
||||
if(!$controller_id){
|
||||
die(json_encode(['code'=>0,'msg'=>'用户不存在']));
|
||||
}
|
||||
|
||||
// 删除用户
|
||||
$result = Db::name('user_controller')->where('id',$controller_id)->delete();
|
||||
if($result){
|
||||
insertAdminLog('删除操作员','删除操作员: | ID: '.$controller_id);
|
||||
die(json_encode(['code'=>1,'msg'=>'已删除!']));
|
||||
}else{
|
||||
die(json_encode(['code'=>1,'msg'=>'删除失败!']));
|
||||
}
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'操作错误!']));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除多个操作员
|
||||
*/
|
||||
public function controller_del_more()
|
||||
{
|
||||
if(Request::instance()->post()){
|
||||
// 接收数据
|
||||
$user_ids = json_decode(Request::instance()->post('user_ids'),true);
|
||||
|
||||
// 验证数据
|
||||
if(empty($user_ids)){
|
||||
die(json_encode(['code'=>0,'msg'=>'删除用户不能为空!']));
|
||||
}else{
|
||||
// 遍历删除多个会员
|
||||
foreach($user_ids as $v){
|
||||
insertAdminLog('删除操作员','删除操作员: | ID: '.$v);
|
||||
Db::name('user_controller')->where('id',$v)->delete();
|
||||
}
|
||||
die(json_encode(['code'=>1,'msg'=>'已删除!']));
|
||||
}
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'操作错误!']));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,241 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\Db;
|
||||
use think\Request;
|
||||
use think\Session;
|
||||
|
||||
class Cs extends Common{
|
||||
/**
|
||||
* 可以洗码的会员及列表
|
||||
*/
|
||||
public function index(){
|
||||
Session::set('allowSubmit','YES');
|
||||
// 接收分页的条件
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get',$get);
|
||||
$this->assign('query',$query);
|
||||
|
||||
// 接收搜索的条件信息
|
||||
$username = Request::instance()->get('username');
|
||||
$startDate = Request::instance()->get('startDate');
|
||||
$endDate = Request::instance()->get('endDate');
|
||||
|
||||
// 时间条件
|
||||
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);
|
||||
}
|
||||
$this->assign('get',$get);
|
||||
|
||||
// 拼装搜索条件
|
||||
$where = array();
|
||||
if(!empty($username)) $where['username'] = $username;
|
||||
$where['is_delete'] = 0;
|
||||
$where['agent'] = 1;
|
||||
$where['agent_parent_id'] = 0;
|
||||
// $where['agent_parent_id'] = 0;
|
||||
// 获取所有代理信息
|
||||
$agent_list = Db::name('user')->where($where)->order('id desc')->paginate(10,false,array('query'=>$get));
|
||||
// 数据查询条件
|
||||
$sumWhere = array();
|
||||
$sumWhere['create_time'] = array('between',[$startTime,$endTime]);
|
||||
foreach($agent_list AS $k => $v){
|
||||
$sumWhere['user_id'] = $v['id'];
|
||||
$sumWhere['status'] = 1;
|
||||
//占股总量
|
||||
$v['total_share_amount'] = Db::name('cs')->where($sumWhere)->sum('share_amount');
|
||||
//已结占股总量
|
||||
$v['checkout_share_amount'] = Db::name('cs')->where($sumWhere)->where(array('is_checkout' => 1))->sum('share_amount');
|
||||
//未结占股总量
|
||||
$v['no_checkout_share_amount'] = Db::name('cs')->where(array('user_id'=>$v['id'],'is_checkout' => 0))->sum('share_amount');
|
||||
//最后结算时间
|
||||
if($v['last_cs_time'] > 0){
|
||||
$v['last_cs_time'] = date('Y-m-d H:i:s',$v['last_cs_time']);
|
||||
}else{
|
||||
$v['last_cs_time'] = '-';
|
||||
}
|
||||
$agent_list[$k] = $v;
|
||||
}
|
||||
// 渲染变量和模板
|
||||
$this->assign('agent_list',$agent_list);
|
||||
return $this->fetch();
|
||||
}
|
||||
//处理洗码
|
||||
public function do_cs(){
|
||||
$result = array();
|
||||
$user_info = Session::get('user_info');
|
||||
if(Request::instance()->post() && intval(Request::instance()->post('user_id')) > 0){
|
||||
$user_id = intval(Request::instance()->post('user_id'));
|
||||
$find = Db::name('user')->where(array('id' => $user_id, 'status' => 1, 'is_delete' => 0))->find();
|
||||
if(!$find){
|
||||
$result['errorCode'] = 1;
|
||||
$result['errorMessage'] = '账号处于非正常状态,请确保账号正常再进行操作';
|
||||
die(json_encode($result));
|
||||
}
|
||||
if($find['agent_parent_id'] > 0) {
|
||||
$result['errorCode'] = 1;
|
||||
$result['errorMessage'] = '不允许结算。请联系其经纪人为其洗码。';
|
||||
die(json_encode($result));
|
||||
}
|
||||
$total = Db::name('cs')->where(array('status' => 1, 'user_id' => $user_id, 'is_checkout' => 0))->sum('share_amount');
|
||||
if($total != 0){
|
||||
//防止重复提交
|
||||
$allowSubmit = Session::get('allowSubmit');
|
||||
if($allowSubmit == 'YES'){
|
||||
Session::delete('allowSubmit');
|
||||
}else{
|
||||
Session::delete('allowSubmit');
|
||||
die(json_encode(['errorCode' => 1, 'errorMessage' => "请勿重复提交"]));
|
||||
}
|
||||
//查找下边的会员
|
||||
$uodateRusult = Db::name('cs')->where(array('status' => 1, 'user_id' => $user_id, 'is_checkout' => 0))->update(array('is_checkout' => 1,'checkout_time' => time()));
|
||||
if($uodateRusult){
|
||||
//记录到结算日志
|
||||
$insertData = array();
|
||||
$insertData['user_id'] = $user_id;
|
||||
$insertData['username'] = $find['username'];
|
||||
$insertData['share_amount'] = $total;
|
||||
$insertData['agent_cs'] = $find['agent_cs'];
|
||||
$insertData['create_time'] = time();
|
||||
$insertData['old_money'] = 0;
|
||||
$insertData['new_money'] = 0;
|
||||
$insertData['admin_id'] = $user_info['id'];
|
||||
$insertData['admin_username'] = $user_info['admin'];
|
||||
$insertData['admin_or_agent'] = 1;
|
||||
Db::name('cs_log')->insert($insertData);
|
||||
//上分表增加记录
|
||||
$rechargeData = array();
|
||||
$rechargeData['type'] = 3;
|
||||
$rechargeData['amount'] = $total;
|
||||
if($total > 0){
|
||||
$rechargeData['mode'] = 1;
|
||||
}else{
|
||||
$rechargeData['mode'] = 2;
|
||||
}
|
||||
$rechargeData['agent_or_admin'] = 1;
|
||||
$rechargeData['user_id'] = $user_id;
|
||||
$rechargeData['user_type'] = $find['agent'];
|
||||
$rechargeData['user_agent_level'] = $find['agent_level'];
|
||||
$rechargeData['username_for'] = $find['username'];
|
||||
$rechargeData['nickname_for'] = $find['nickname'];
|
||||
$rechargeData['user_parent_id'] = $find['agent_parent_id'];
|
||||
$rechargeData['admin_id'] = $user_info['id'];
|
||||
$rechargeData['admin_user_name'] = $user_info['admin'];
|
||||
$rechargeData['create_time'] = time();
|
||||
$rechargeData['old_money'] = $find['money'];
|
||||
$rechargeData['new_money'] = $find['money'];
|
||||
$rechargeData['remake'] = '总后台操作占股结算,不会增加其余分,只做现金结算';
|
||||
Db::name('recharge')->insert($rechargeData);
|
||||
Db::name('user')->where(array('id' => $user_id))->update(array('last_cs_time' => time()));
|
||||
}
|
||||
$result['errorCode'] = 0;
|
||||
$result['errorMessage'] = '结算成功';
|
||||
die(json_encode($result));
|
||||
}else{
|
||||
$result['errorCode'] = 1;
|
||||
$result['errorMessage'] = '占股结算数目不能等于0';
|
||||
die(json_encode($result));
|
||||
}
|
||||
}else{
|
||||
$result['errorCode'] = 1;
|
||||
$result['errorMessage'] = 'ERROR';
|
||||
die(json_encode($result));
|
||||
}
|
||||
}
|
||||
public function cs_check(){
|
||||
// 接收分页的条件
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('query',$query);
|
||||
|
||||
// 接收搜索条件
|
||||
$username = Request::instance()->get('username');
|
||||
$startDate = Request::instance()->get('startDate');
|
||||
$endDate = Request::instance()->get('endDate');
|
||||
$export = Request::instance()->get('export');
|
||||
$admin_or_agent = intval(Request::instance()->get('admin_or_agent'));
|
||||
|
||||
// 时间条件
|
||||
$endTime = time();
|
||||
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);
|
||||
}
|
||||
$this->assign('get',$get);
|
||||
|
||||
// 拼装搜索条件
|
||||
$where = array();
|
||||
if(!empty($username)) $where['username'] = $username;
|
||||
$where['create_time'] = array('between',[$startTime,$endTime]);
|
||||
if($admin_or_agent > 0) $where['admin_or_agent'] = $admin_or_agent;
|
||||
|
||||
if($export == 1){
|
||||
$cs_list = Db::name('cs_log')->where($where)->order('create_time desc')->select();
|
||||
}else{
|
||||
// 所有的洗码记录
|
||||
$cs_list = Db::name('cs_log')->where($where)->order('create_time desc')->paginate(10,false,array('query'=>$get));
|
||||
}
|
||||
foreach($cs_list as $k => $v){
|
||||
// 操作人
|
||||
if($v['admin_or_agent'] == 1 ){
|
||||
$v['connection_username'] = $v['admin_username'];
|
||||
$v['admin_or_agent_msg'] = '总台操作';
|
||||
}else{
|
||||
$v['admin_or_agent_msg'] = '代理操作';
|
||||
}
|
||||
// 数据格式转换
|
||||
$v['share_amount'] = round($v['share_amount'],2);
|
||||
$v['agent_cs'] = round($v['agent_cs'],2);
|
||||
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
|
||||
$cs_list[$k] = $v;
|
||||
}
|
||||
|
||||
//导出excel列表
|
||||
if($export == 1){
|
||||
if($cs_list){
|
||||
//重新组合
|
||||
$excelData = array();
|
||||
foreach($cs_list AS $k => $v){
|
||||
$excelData[$k][0] = $v['username'];
|
||||
$excelData[$k][1] = $v['agent_cs'];
|
||||
$excelData[$k][2] = $v['share_amount'];
|
||||
$excelData[$k][3] = $v['connection_username'];
|
||||
$excelData[$k][4] = $v['create_time'];
|
||||
$excelData[$k][5] = $v['admin_or_agent_msg'];
|
||||
}
|
||||
$title = array('账号','占成(%)','占股结算金额','操作人','结算时间','备注');
|
||||
if($startDate && $endDate){
|
||||
$this->exportExcelCore($excelData, '占股结算记录-'.$startDate."-".$endDate, $title);
|
||||
}else{
|
||||
$this->exportExcelCore($excelData, '占股结算记录', $title);
|
||||
}
|
||||
exit('已导出支持列表,请不要重复刷新该页面!');
|
||||
}else{
|
||||
exit('没有可以导出的列表!');
|
||||
}
|
||||
}
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('cs_list',$cs_list);
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,464 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\Db;
|
||||
use think\Request;
|
||||
use think\Session;
|
||||
|
||||
class Game extends Common{
|
||||
public function delete_table(){
|
||||
if(Request::instance()->isPost()){
|
||||
$table_id = intval(Request::instance()->post('table_id'));
|
||||
if($table_id > 0){
|
||||
$status = Db::name('table')->where(array('id' => $table_id))->value('status');
|
||||
if($status == 1){
|
||||
Db::name('table')->where(array('id' => $table_id))->limit(1)->update(array('status' => 0));
|
||||
}else{
|
||||
Db::name('table')->where(array('id' => $table_id))->limit(1)->update(array('status' => 1));
|
||||
}
|
||||
return json(array('Success' => 1, 'Msg' => '操作成功'));
|
||||
}else{
|
||||
return json(array('Success' => 0, 'Msg' => '操作失败'));
|
||||
}
|
||||
}
|
||||
}
|
||||
public function index(){
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get',$get);
|
||||
$this->assign('query',$query);
|
||||
$table_name = trim(Request::instance()->get('table_name'));
|
||||
$where = array();
|
||||
if($table_name != ''){
|
||||
$where['table_name'] = $table_name;
|
||||
}
|
||||
$table_info = Db::name('user_controller')->alias('a')->join('table b','a.table_id = b.id')->where($where)->order('table_id desc')->select();
|
||||
foreach($table_info as $k => $v){
|
||||
$v['number_total'] = Db::name('number_tab')->where('table_id',$v['id'])->count();
|
||||
$v['boot_total'] = Db::name('boot')->where('table_id',$v['id'])->count();
|
||||
if($v['bet_type'] == 1){
|
||||
$v['bet_type'] = '网络投注';
|
||||
}elseif($v['bet_type'] == 2){
|
||||
$v['bet_type'] = '电话投注';
|
||||
}elseif($v['bet_type'] == 3){
|
||||
$v['bet_type'] = '所有投注';
|
||||
}else{
|
||||
$v['bet_type'] = '无';
|
||||
}
|
||||
|
||||
$table_info[$k] = $v;
|
||||
}
|
||||
$this->assign('table_info',$table_info);
|
||||
return $this->fetch();
|
||||
}
|
||||
public function edit_table_info(){
|
||||
$table_id = Request::instance()->get('table_id');
|
||||
$table_info = Db::name('user_controller')->alias('a')->join('table b','a.table_id = b.id')->where('is_delete',0)->where("table_id",$table_id)->find();
|
||||
$table_info['min_bankerplayer'] = substr($table_info['limit_money'],0,strpos($table_info['limit_money'], '-'));
|
||||
$table_info['max_bankerplayer'] = substr(strstr($table_info['limit_money'], '-'),1);
|
||||
$table_info['min_tie'] = substr($table_info['limit_money_tie'],0,strpos($table_info['limit_money_tie'], '-'));
|
||||
$table_info['max_tie'] = substr(strstr($table_info['limit_money_tie'], '-'),1);
|
||||
$table_info['min_pair'] = substr($table_info['limit_money_pair'],0,strpos($table_info['limit_money_pair'], '-'));
|
||||
$table_info['max_pair'] = substr(strstr($table_info['limit_money_pair'], '-'),1);
|
||||
// 渲染参数和模板
|
||||
$this->assign('table_info',$table_info);
|
||||
return $this->fetch();
|
||||
}
|
||||
public function do_edit_table_info(){
|
||||
$table_id = $this->request->param('table_id');
|
||||
$table_info = Db::name('table')->where('id',$table_id)->find();
|
||||
$table_num = $this->request->param('table_num');
|
||||
$table_name = $this->request->param('table_name');
|
||||
$bet_type = $this->request->param('bet_type');
|
||||
$seat_num = $this->request->param('seat_num');
|
||||
|
||||
|
||||
$min_bankerplayer = $this->request->param('min_bankerplayer');
|
||||
$max_bankerplayer = $this->request->param('max_bankerplayer');
|
||||
$min_tie = $this->request->param('min_tie');
|
||||
$max_tie = $this->request->param('max_tie');
|
||||
$min_pair = $this->request->param('min_pair');
|
||||
$max_pair = $this->request->param('max_pair');
|
||||
$wait_time = $this->request->param('wait_time');
|
||||
$is_scavenging = $this->request->param('is_scavenging');
|
||||
|
||||
$newPassword = $this->request->param('newPassword');
|
||||
$confirmNewPassword = $this->request->param('confirmNewPassword');
|
||||
if($table_num <= 0){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请填写桌台号为数字!';
|
||||
return $msg;
|
||||
}
|
||||
if(!$table_name){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请填写桌台名称!';
|
||||
return $msg;
|
||||
}
|
||||
if($bet_type <= 0){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请选择投注方式!';
|
||||
return $msg;
|
||||
}
|
||||
if(!$min_bankerplayer || !$max_bankerplayer){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请填写完整网络-庄闲限红!';
|
||||
return $msg;
|
||||
}
|
||||
if($table_info['game_id'] == 1 || $table_info['game_id'] == 2){
|
||||
if(!$min_tie || !$max_tie){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请填写完整网络-和限红!';
|
||||
return $msg;
|
||||
}
|
||||
}
|
||||
if($table_info['game_id'] == 1){
|
||||
if(!$min_pair || !$max_pair){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请填写完整网络-对限红!';
|
||||
return $msg;
|
||||
}
|
||||
}
|
||||
if(!$wait_time){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请填写等待开牌时间!';
|
||||
return $msg;
|
||||
}
|
||||
if($newPassword){
|
||||
if(strlen($newPassword) < 6 || strlen($newPassword) > 20){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '密码长度必须是6到20个字符!';
|
||||
return $msg;
|
||||
}
|
||||
if(!$confirmNewPassword){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请再次输入密码!';
|
||||
return $msg;
|
||||
}
|
||||
if($newPassword != $confirmNewPassword){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '两次输入的密码不一致!';
|
||||
return $msg;
|
||||
}
|
||||
}
|
||||
if($confirmNewPassword){
|
||||
if(!$newPassword){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请填写新密码!';
|
||||
return $msg;
|
||||
}
|
||||
}
|
||||
$update = array();
|
||||
$update['b.table_num'] = $table_num;
|
||||
$update['b.table_name'] = $table_name;
|
||||
$update['b.bet_type'] = $bet_type;
|
||||
$update['b.seat_num'] = $seat_num;
|
||||
$update['b.limit_money'] = $min_bankerplayer.'-'.$max_bankerplayer;
|
||||
if($table_info['game_id'] == 1 || $table_info['game_id'] == 2){
|
||||
$update['b.limit_money_tie'] = $min_tie.'-'.$max_tie;
|
||||
}
|
||||
if($table_info['game_id'] == 1){
|
||||
$update['b.limit_money_pair'] = $min_pair.'-'.$max_pair;
|
||||
}
|
||||
$update['b.wait_time'] = $wait_time;
|
||||
$update['b.is_scavenging'] = $is_scavenging;
|
||||
|
||||
$update['b.media_far_rtmp'] = trim($this->request->param('media_far_rtmp'));
|
||||
$update['b.media_far_flv'] = trim($this->request->param('media_far_flv'));
|
||||
$update['b.media_far_ws'] = trim($this->request->param('media_far_ws'));
|
||||
$update['b.media_near_rtmp'] = trim($this->request->param('media_near_rtmp'));
|
||||
$update['b.media_near_flv'] = trim($this->request->param('media_near_flv'));
|
||||
$update['b.media_near_ws'] = trim($this->request->param('media_near_ws'));
|
||||
|
||||
$update['b.limit_money_total'] = intval($this->request->param('limit_money_total'));
|
||||
$update['b.limit_money_tie_total'] = intval($this->request->param('limit_money_tie_total'));
|
||||
$update['b.limit_money_pair_total'] = intval($this->request->param('limit_money_pair_total'));
|
||||
|
||||
$update['b.sort'] = intval($this->request->param('sort'));
|
||||
|
||||
$update['b.interval_time'] = intval($this->request->param('interval_time'));
|
||||
$update['b.card_first_type'] = intval($this->request->param('card_first_type'));
|
||||
|
||||
if($newPassword){
|
||||
$update['a.password'] = think_ucenter_md5($newPassword,UC_AUTH_KEY);
|
||||
}
|
||||
$update['b.phone'] = trim($this->request->param('phone'));
|
||||
if($update['b.phone']){
|
||||
$findPhone = Db::name('table')->where(['phone'=>$update['b.phone']])->where('id','<>',$table_id)->find();
|
||||
if($findPhone){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '手机号已被使用!';
|
||||
return $msg;
|
||||
}
|
||||
}
|
||||
Db::name('user_controller')->alias('a')->join('table b','a.table_id = b.id')->where('a.is_delete',0)->where("a.table_id",$table_id)->update($update);
|
||||
$msg['status'] = 2;
|
||||
$msg['code'] = '修改成功';
|
||||
return $msg;
|
||||
}
|
||||
|
||||
public function add_table(){
|
||||
return $this->fetch();
|
||||
}
|
||||
public function do_add_table(){
|
||||
$table['table_num'] = $this->request->param('table_num');
|
||||
$table['table_name'] = $this->request->param('table_name');
|
||||
$table['game_id'] = $this->request->param('game_id');
|
||||
/*
|
||||
if($table['game_id'] == 1){
|
||||
$table['mode'] = $this->request->param('mode');
|
||||
}
|
||||
*/
|
||||
$min_bankerplayer = $this->request->param('min_bankerplayer');
|
||||
$max_bankerplayer = $this->request->param('max_bankerplayer');
|
||||
if($table['game_id'] == 1 || $table['game_id'] == 2){
|
||||
$min_tie = $this->request->param('min_tie');
|
||||
$max_tie = $this->request->param('max_tie');
|
||||
}
|
||||
if($table['game_id'] == 1){
|
||||
$min_pair = $this->request->param('min_pair');
|
||||
$max_pair = $this->request->param('max_pair');
|
||||
}
|
||||
$wait_time = $this->request->param('wait_time');
|
||||
$rob_time = $this->request->param('rob_time');
|
||||
$is_scavenging = $this->request->param('is_scavenging');
|
||||
$is_rob = $this->request->param('is_rob');
|
||||
|
||||
if (is_null($is_rob)) $is_rob = 0;
|
||||
|
||||
$remarks = $this->request->param('remarks');
|
||||
$bet_type = $this->request->param('bet_type');
|
||||
$controller['username'] = $this->request->param('username');
|
||||
$newPassword = $this->request->param('newPassword');
|
||||
$confirmNewPassword = $this->request->param('confirmNewPassword');
|
||||
$controller['nickname'] = $this->request->param('nickname');
|
||||
$table['phone'] = trim($this->request->param('phone'));
|
||||
|
||||
$is_localhost_control = intval($this->request->param('is_localhost_control'));
|
||||
$limit_banker_amount = intval($this->request->param('limit_banker_amount'));
|
||||
if($is_localhost_control == 1 && $is_scavenging == 1){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '桌子选择扫牌,则只能选择网络控制';
|
||||
return $msg;
|
||||
}
|
||||
|
||||
if($table['table_num'] <= 0){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请填写桌台号为数字!';
|
||||
return $msg;
|
||||
}
|
||||
if(!$table['table_name']){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请填写桌台名称!';
|
||||
return $msg;
|
||||
}
|
||||
$is_table_name = Db::name('table')->where(array('table_name' => $table['table_name'], 'status' => 1))->find();
|
||||
if($is_table_name){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '该桌台已经存在,请输入新的桌台名称!';
|
||||
return $msg;
|
||||
}
|
||||
if(!$table['game_id']){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请选择游戏名称!';
|
||||
return $msg;
|
||||
}
|
||||
/*
|
||||
if($table['game_id'] == 1){
|
||||
if(!$table['mode']){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请选择游戏模式!';
|
||||
return $msg;
|
||||
}
|
||||
}
|
||||
*/
|
||||
if($bet_type <= 0){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请选择游戏模式!';
|
||||
return $msg;
|
||||
}
|
||||
if(!$min_bankerplayer || !$max_bankerplayer){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请填写完整网络-庄闲限红!';
|
||||
return $msg;
|
||||
}
|
||||
if($table['game_id'] == 1 || $table['game_id'] == 2){
|
||||
if(!$min_tie || !$max_tie){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请填写完整网络-和限红!';
|
||||
return $msg;
|
||||
}
|
||||
}
|
||||
if($table['game_id'] == 1){
|
||||
if(!$min_pair || !$max_pair){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请填写完整网络-对限红!';
|
||||
return $msg;
|
||||
}
|
||||
}
|
||||
if(!$controller['username']){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请填写账户名!';
|
||||
return $msg;
|
||||
}
|
||||
if(!$newPassword){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请填写密码!';
|
||||
return $msg;
|
||||
}
|
||||
if(strlen($newPassword) < 6 || strlen($newPassword) > 20){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '密码长度必须是6到20个字符!';
|
||||
return $msg;
|
||||
}
|
||||
if(!$confirmNewPassword){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请再次填写密码!';
|
||||
return $msg;
|
||||
}
|
||||
if($newPassword != $confirmNewPassword){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '两次输入的密码不一致!';
|
||||
return $msg;
|
||||
}
|
||||
if(!$controller['nickname']){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请填写昵称!';
|
||||
return $msg;
|
||||
}
|
||||
if($table['game_id'] == 1){
|
||||
$table['game_name'] = '百家乐';
|
||||
$table['is_rob'] = 0;
|
||||
}else if($table['game_id'] == 2){
|
||||
$table['game_name'] = '龙虎斗';
|
||||
/*
|
||||
$table['mode'] = 0;
|
||||
$table['special_num'] = 0;
|
||||
$table['percent_num'] = 0.00;
|
||||
*/
|
||||
$table['is_rob'] = 0;
|
||||
}else if($table['game_id'] == 4){
|
||||
$table['game_name'] = '牛牛';
|
||||
/*
|
||||
$table['mode'] = 0;
|
||||
$table['special_num'] = 0;
|
||||
$table['percent_num'] = 0.00;
|
||||
*/
|
||||
$table['is_rob'] = $is_rob;
|
||||
}else if($table['game_id'] == 5){
|
||||
$table['game_name'] = '三卡牛牛';
|
||||
/*
|
||||
$table['mode'] = 0;
|
||||
$table['special_num'] = 0;
|
||||
$table['percent_num'] = 0.00;
|
||||
*/
|
||||
$table['is_rob'] = $is_rob;
|
||||
}else if($table['game_id'] == 6){
|
||||
$table['game_name'] = '色碟';
|
||||
/*
|
||||
$table['mode'] = 0;
|
||||
$table['special_num'] = 0;
|
||||
$table['percent_num'] = 0.00;
|
||||
*/
|
||||
$table['is_rob'] = $is_rob;
|
||||
}else if($table['game_id'] == 7){
|
||||
$table['game_name'] = '骰宝';
|
||||
/*
|
||||
$table['mode'] = 0;
|
||||
$table['special_num'] = 0;
|
||||
$table['percent_num'] = 0.00;
|
||||
*/
|
||||
$table['is_rob'] = $is_rob;
|
||||
}else if($table['game_id'] == 8){
|
||||
$table['game_name'] = '轮盘';
|
||||
/*
|
||||
$table['mode'] = 0;
|
||||
$table['special_num'] = 0;
|
||||
$table['percent_num'] = 0.00;
|
||||
*/
|
||||
$table['is_rob'] = $is_rob;
|
||||
}
|
||||
/*
|
||||
if($table['mode'] == 1){
|
||||
$table['special_num'] = 0;
|
||||
$table['percent_num'] = 0.00;
|
||||
}else if($table['mode'] == 2){
|
||||
$table['special_num'] = 6;
|
||||
$table['percent_num'] = 0.50;
|
||||
}
|
||||
*/
|
||||
$table['table_limit'] = 0.00;
|
||||
$table['limit_money'] = $min_bankerplayer.'-'.$max_bankerplayer;
|
||||
if($table['game_id'] == 1 || $table['game_id'] == 2){
|
||||
$table['limit_money_tie'] = $min_tie.'-'.$max_tie;
|
||||
}
|
||||
if($table['game_id'] == 1){
|
||||
$table['limit_money_pair'] = $min_pair.'-'.$max_pair;
|
||||
}
|
||||
$table['is_scavenging'] = $is_scavenging;
|
||||
// $table['is_rob'] = $is_rob;
|
||||
if($table['game_id'] == 5){
|
||||
if($table['is_rob'] == 1){
|
||||
if(!$limit_banker_amount){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请填写上庄金额!';
|
||||
return $msg;
|
||||
}
|
||||
$table['limit_banker_amount'] = $limit_banker_amount;
|
||||
}
|
||||
}
|
||||
$table['media_far_rtmp'] = trim($this->request->param('media_far_rtmp'));
|
||||
$table['media_far_flv'] = trim($this->request->param('media_far_flv'));
|
||||
$table['media_far_ws'] = trim($this->request->param('media_far_ws'));
|
||||
$table['media_near_rtmp'] = trim($this->request->param('media_near_rtmp'));
|
||||
$table['media_near_flv'] = trim($this->request->param('media_near_flv'));
|
||||
$table['media_near_ws'] = trim($this->request->param('media_near_ws'));
|
||||
$table['limit_money_total'] = intval($this->request->param('limit_money_total'));
|
||||
$table['limit_money_tie_total'] = intval($this->request->param('limit_money_tie_total'));
|
||||
$table['limit_money_pair_total'] = intval($this->request->param('limit_money_pair_total'));
|
||||
|
||||
$table['bet_type'] = $bet_type;
|
||||
$table['is_localhost_control'] = $is_localhost_control;
|
||||
|
||||
$table['interval_time'] = intval($this->request->param('interval_time'));
|
||||
$table['card_first_type'] = intval($this->request->param('card_first_type'));
|
||||
|
||||
$table['seat_num'] = intval($this->request->param('seat_num'));
|
||||
|
||||
if($remarks){
|
||||
$table['remake'] = $remarks;
|
||||
}
|
||||
if($wait_time){
|
||||
$table['wait_time'] = $wait_time;
|
||||
}
|
||||
if($table['phone']){
|
||||
$findPhone = Db::name('table')->where(['phone'=>$table['phone']])->find();
|
||||
if($findPhone){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '手机号已被使用!';
|
||||
return $msg;
|
||||
}
|
||||
}
|
||||
|
||||
$is_table = Db::name('table')->insert($table);
|
||||
if($is_table == 1){
|
||||
$controller['table_id'] = Db::name('table')->getLastInsID();
|
||||
$controller['password'] = think_ucenter_md5($newPassword,UC_AUTH_KEY);
|
||||
$controller['encrypt'] = getRandChar();
|
||||
$is_controller = Db::name('user_controller')->insert($controller);
|
||||
if($is_controller){
|
||||
$msg['status'] = 2;
|
||||
$msg['code'] = '添加成功!';
|
||||
return $msg;
|
||||
}else{
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '添加失败,请稍后再试!';
|
||||
return $msg;
|
||||
}
|
||||
}else{
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '添加失败,请稍后再试!';
|
||||
return $msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\Db;
|
||||
use think\Session;
|
||||
use think\Request;
|
||||
|
||||
class Index extends Common{
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
}
|
||||
public function check_cashout(){
|
||||
if(Request::instance()->isPost()){
|
||||
$receivables_record = Db::name('receivables_record')->where(array('record_type' => 2, 'status' => 0))->order('id DESC')->find();
|
||||
if($receivables_record){
|
||||
return json(array('code' => 1));
|
||||
}else{
|
||||
return json(array('code' => 0));
|
||||
}
|
||||
}else{
|
||||
die('请求错误,请退出页面');
|
||||
}
|
||||
}
|
||||
public function index(){
|
||||
$user_info = Session::get('user_info');
|
||||
$this->assign('user_info',$user_info);
|
||||
$this->assign('admin',$user_info['admin']);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 关系链
|
||||
public function relation(){
|
||||
// 接收要修改的下属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){
|
||||
$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'] = '代理';
|
||||
$data['color'] = '#FF5722';
|
||||
}else{
|
||||
$data['agent'] = '会员';
|
||||
$data['color'] = '#008dfd';
|
||||
}
|
||||
$relation[] = $data;
|
||||
}
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('relation',$relation);
|
||||
return $this->fetch();
|
||||
}
|
||||
public function print_user_bet(){
|
||||
$user_id = intval(Request::instance()->get('user_id'));
|
||||
$all_bet = DB::name('bet')->alias('b')->join('cg_number_tab n','b.number_tab_id=n.id')->where(array('b.user_id' => $user_id, 'b.status' => 1))->where('game_id','>',0)->where('game_id','<',3)->order('b.create_time DESC')->field('b.*,n.bet_end_time')->select();
|
||||
if($all_bet){
|
||||
//重新组合
|
||||
$excelData = array();
|
||||
foreach($all_bet AS $k => $v){
|
||||
$excelData[$k][0] = $v['username'];
|
||||
$excelData[$k][1] = $v['table_name'];
|
||||
$excelData[$k][2] = $v['boot_num'];
|
||||
$excelData[$k][3] = $v['number'];
|
||||
if($v['game_id'] == 1){
|
||||
if($v['result'] == 1){
|
||||
if($v['pair'] == 1){
|
||||
$excelData[$k][4] = '庄-庄对';
|
||||
}elseif($v['pair'] == 2){
|
||||
$excelData[$k][4] = '庄-闲对';
|
||||
}elseif($v['pair'] == 3){
|
||||
$excelData[$k][4] = '庄-庄闲对';
|
||||
}else{
|
||||
$excelData[$k][4] = '庄';
|
||||
}
|
||||
}elseif($v['result'] == 2){
|
||||
if($v['pair'] == 1){
|
||||
$excelData[$k][4] = '闲-庄对';
|
||||
}elseif($v['pair'] == 2){
|
||||
$excelData[$k][4] = '闲-闲对';
|
||||
}elseif($v['pair'] == 3){
|
||||
$excelData[$k][4] = '闲-庄闲对';
|
||||
}else{
|
||||
$excelData[$k][4] = '闲';
|
||||
}
|
||||
}elseif($v['result'] == 3){
|
||||
if($v['pair'] == 1){
|
||||
$excelData[$k][4] = '和-庄对';
|
||||
}elseif($v['pair'] == 2){
|
||||
$excelData[$k][4] = '和-闲对';
|
||||
}elseif($v['pair'] == 3){
|
||||
$excelData[$k][4] = '和-庄闲对';
|
||||
}else{
|
||||
$excelData[$k][4] = '和';
|
||||
}
|
||||
}else{
|
||||
$excelData[$k][4] = '';
|
||||
}
|
||||
}else{
|
||||
if($v['result'] == 1){
|
||||
$excelData[$k][4] = '龙';
|
||||
}elseif($v['result'] == 2){
|
||||
$excelData[$k][4] = '虎';
|
||||
}elseif($v['result'] == 3){
|
||||
$excelData[$k][4] = '和';
|
||||
}else{
|
||||
$excelData[$k][4] = '';
|
||||
}
|
||||
}
|
||||
$excelData[$k][5] = $v['money_before_bet'];
|
||||
$excelData[$k][6] = $v['money'];
|
||||
$excelData[$k][7] = $v['end_money'];
|
||||
$excelData[$k][8] = $v['win_total'];
|
||||
$excelData[$k][9] = $v['banker_amount'];
|
||||
$excelData[$k][10] = $v['player_amount'];
|
||||
$excelData[$k][11] = $v['tie_amount'];
|
||||
if($v['game_id'] == 1){
|
||||
$excelData[$k][12] = $v['banker_pair_amount'];
|
||||
$excelData[$k][13] = $v['player_pair_amount'];
|
||||
}else{
|
||||
$excelData[$k][12] = '';
|
||||
$excelData[$k][13] = '';
|
||||
}
|
||||
$excelData[$k][14] = date('Y-m-d H:i:s',$v['create_time']);
|
||||
$excelData[$k][15] = date('Y-m-d H:i:s',$v['bet_end_time']);
|
||||
}
|
||||
$title = array('用户名','下注桌子','靴号','铺号','结果','下注前余额','下注后余额','开结果后余额','总赢','庄下注额','闲下注额','和下注额','庄对下注额','闲对下注额','下注时间','封盘时间');
|
||||
$this->exportExcelCore($excelData, '下注明细', $title);
|
||||
exit('已导出支持列表,请不要重复刷新该页面!');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\Db;
|
||||
use think\Request;
|
||||
use think\Session;
|
||||
|
||||
class Info extends Common{
|
||||
public function index(){
|
||||
$user_info = Session::get('user_info');
|
||||
$last_login_info = Session::get('last_login_info');
|
||||
$last_login_info['last_login_time'] = date('Y-m-d H:i:s',$last_login_info['last_login_time']);
|
||||
$this->assign('last_login_info',$last_login_info);
|
||||
$this->assign('user_info',$user_info);
|
||||
$system_info = Db::name('system')->where(array('id' => 1))->find();
|
||||
$this->assign('system_info',$system_info);
|
||||
$this->assign('user_info',$user_info);
|
||||
return $this->fetch();
|
||||
}
|
||||
public function pass_edit(){
|
||||
$user_info = Session::get('user_info');
|
||||
$this->assign('user_info',$user_info);
|
||||
return $this->fetch();
|
||||
}
|
||||
//修改密码
|
||||
public function update_password(){
|
||||
$id = $this->request->param('id');
|
||||
$oldPassword = $this->request->param('oldPassword');
|
||||
$newPassword = $this->request->param('newPassword');
|
||||
$confirmNewPassword = $this->request->param('confirmNewPassword');
|
||||
if(!$oldPassword){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请填写旧密码!';
|
||||
return $msg;
|
||||
}
|
||||
$user_pass = Db::name('admin')->where('id',$id)->value('password');
|
||||
$oldPassword = think_ucenter_md5($oldPassword,UC_AUTH_KEY);
|
||||
if($user_pass != $oldPassword){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '原密码错误';
|
||||
return $msg;
|
||||
}
|
||||
if(!$newPassword){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请填写新密码!';
|
||||
return $msg;
|
||||
}
|
||||
if(strlen($newPassword) < 6 || strlen($newPassword) > 20){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '密码长度必须是6到20个字符!';
|
||||
return $msg;
|
||||
}
|
||||
if(!$confirmNewPassword){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请再次填写新密码!';
|
||||
return $msg;
|
||||
}
|
||||
if($newPassword != $confirmNewPassword){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '两次输入的密码不一致!';
|
||||
return $msg;
|
||||
}
|
||||
$newPassword = think_ucenter_md5($newPassword,UC_AUTH_KEY);
|
||||
$is_passwprd = Db::name('admin')->where('id',$id)->update(['password' => $newPassword]);
|
||||
if($is_passwprd == 1){
|
||||
$msg['status'] = 2;
|
||||
$msg['code'] = '修改成功';
|
||||
}else{
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '修改失败,请稍后再试';
|
||||
}
|
||||
return $msg;
|
||||
}
|
||||
//修改个人信息
|
||||
public function update_info(){
|
||||
$casino_name = $this->request->param('casino_name');
|
||||
$ws_url = $this->request->param('ws_url');
|
||||
$pc_video = $this->request->param('pc_video');
|
||||
$wap_video = $this->request->param('wap_video');
|
||||
$is_update = Db::name('system')->where('id',1)->update(['casino_name' => $casino_name,'ws_url' => $ws_url,'pc_video' => $pc_video,'wap_video' => $wap_video]);
|
||||
if($is_update == 1){
|
||||
$msg['status'] = 2;
|
||||
$msg['code'] = '修改成功';
|
||||
}else{
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '修改成功';
|
||||
}
|
||||
return $msg;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,574 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\Db;
|
||||
use think\Request;
|
||||
|
||||
class Log extends Common
|
||||
{
|
||||
// 代理操作日志
|
||||
public function index()
|
||||
{
|
||||
// 接收分页的条件
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get',$get);
|
||||
$this->assign('query',$query);
|
||||
|
||||
// 接收搜索参数
|
||||
$username = Request::instance()->get('username');
|
||||
$startDate = Request::instance()->get('startDate');
|
||||
$endDate = Request::instance()->get('endDate');
|
||||
$export = Request::instance()->get('export');
|
||||
$startTime = 0;
|
||||
$endTime = time();
|
||||
|
||||
// 拼装搜索条件
|
||||
$where = array();
|
||||
if(!empty($username)) $where['username'] = array('like',"%".$username."%");
|
||||
if($startDate) $startTime = strtotime($startDate);
|
||||
if($endDate) $endTime = strtotime($endDate);
|
||||
$where['control_time'] = array('between',[$startTime,$endTime]);
|
||||
|
||||
if($export == 1){
|
||||
$log_list = Db::name('agent_log')->where($where)->order('control_time desc')->select();
|
||||
}else{
|
||||
// 查询所有的日志信息
|
||||
$log_list = Db::name('agent_log')->where($where)->order('control_time desc')->paginate(15,false,array('query'=>$get));
|
||||
}
|
||||
$log_sum = Db::name('agent_log')->count();
|
||||
foreach($log_list as $k => $v){
|
||||
$v['control_time'] = date('Y-m-d H:i:s',$v['control_time']);
|
||||
if(empty($v['ip_location'])) $v['ip_location'] = "无";
|
||||
$log_list[$k] = $v;
|
||||
}
|
||||
|
||||
//导出excel列表
|
||||
if($export == 1){
|
||||
if($log_list){
|
||||
//重新组合
|
||||
$excelData = array();
|
||||
foreach($log_list AS $k => $v){
|
||||
$excelData[$k][0] = $v['username'];
|
||||
$excelData[$k][1] = $v['control'];
|
||||
$excelData[$k][2] = $v['remake'];
|
||||
$excelData[$k][3] = $v['control_time'];
|
||||
}
|
||||
$title = array('操作人','操作类型','操作描述','操作时间');
|
||||
if($startDate && $endDate){
|
||||
$this->exportExcelCore($excelData, '操作日志-'.$startDate."-".$endDate, $title);
|
||||
}else{
|
||||
$this->exportExcelCore($excelData, '操作日志', $title);
|
||||
}
|
||||
exit('已导出支持列表,请不要重复刷新该页面!');
|
||||
}else{
|
||||
exit('没有可以导出的列表!');
|
||||
}
|
||||
}
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('log_list',$log_list);
|
||||
$this->assign('log_sum',$log_sum);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 代理操作日志
|
||||
public function admin()
|
||||
{
|
||||
// 接收分页的条件
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get',$get);
|
||||
$this->assign('query',$query);
|
||||
|
||||
// 接收搜索参数
|
||||
$username = Request::instance()->get('username');
|
||||
$startDate = Request::instance()->get('startDate');
|
||||
$endDate = Request::instance()->get('endDate');
|
||||
$export = Request::instance()->get('export');
|
||||
$startTime = 0;
|
||||
$endTime = time();
|
||||
|
||||
// 拼装搜索条件
|
||||
$where = array();
|
||||
if(!empty($username)) $where['space_admin'] = array('like',"%".$username."%");
|
||||
if($startDate) $startTime = strtotime($startDate);
|
||||
if($endDate) $endTime = strtotime($endDate);
|
||||
$where['control_time'] = array('between',[$startTime,$endTime]);
|
||||
|
||||
if($export == 1){
|
||||
$log_list = Db::name('space_system_log')->where($where)->order('control_time desc')->select();
|
||||
}else{
|
||||
// 查询所有的日志信息
|
||||
$log_list = Db::name('space_system_log')->where($where)->order('control_time desc')->paginate(10,false,array('query'=>$get));
|
||||
}
|
||||
$log_sum = Db::name('agent_log')->count();
|
||||
foreach($log_list as $k => $v){
|
||||
$v['control_time'] = date('Y-m-d H:i:s',$v['control_time']);
|
||||
if(empty($v['ip_location'])) $v['ip_location'] = "无";
|
||||
$log_list[$k] = $v;
|
||||
}
|
||||
|
||||
//导出excel列表
|
||||
if($export == 1){
|
||||
if($log_list){
|
||||
//重新组合
|
||||
$excelData = array();
|
||||
foreach($log_list AS $k => $v){
|
||||
$excelData[$k][0] = $v['space_admin'];
|
||||
$excelData[$k][1] = $v['control'];
|
||||
$excelData[$k][2] = $v['remake'];
|
||||
$excelData[$k][3] = $v['control_time'];
|
||||
}
|
||||
$title = array('操作人','操作类型','操作描述','操作时间');
|
||||
if($startDate && $endDate){
|
||||
$this->exportExcelCore($excelData, '操作日志-'.$startDate."-".$endDate, $title);
|
||||
}else{
|
||||
$this->exportExcelCore($excelData, '操作日志', $title);
|
||||
}
|
||||
exit('已导出支持列表,请不要重复刷新该页面!');
|
||||
}else{
|
||||
exit('没有可以导出的列表!');
|
||||
}
|
||||
}
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('log_list',$log_list);
|
||||
$this->assign('log_sum',$log_sum);
|
||||
return $this->fetch();
|
||||
}
|
||||
public function admin_print(){
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$username = Request::instance()->get('username');
|
||||
$startDate = Request::instance()->get('startDate');
|
||||
$endDate = Request::instance()->get('endDate');
|
||||
$startTime = 0;
|
||||
$endTime = time();
|
||||
$where = array();
|
||||
if(!empty($username)) $where['space_admin'] = array('like',"%".$username."%");
|
||||
if($startDate) $startTime = strtotime($startDate);
|
||||
if($endDate) $endTime = strtotime($endDate);
|
||||
$where['control_time'] = array('between',[$startTime,$endTime]);
|
||||
$log_list = Db::name('space_system_log')->where($where)->order('control_time desc')->select();
|
||||
$log_sum = Db::name('agent_log')->count();
|
||||
foreach($log_list as $k => $v){
|
||||
$v['control_time'] = date('Y-m-d H:i:s',$v['control_time']);
|
||||
if(empty($v['ip_location'])) $v['ip_location'] = "无";
|
||||
$log_list[$k] = $v;
|
||||
}
|
||||
$this->assign('log_list',$log_list);
|
||||
$this->assign('log_sum',$log_sum);
|
||||
return $this->fetch();
|
||||
}
|
||||
public function user_print(){
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$username = Request::instance()->get('username');
|
||||
$startDate = Request::instance()->get('startDate');
|
||||
$endDate = Request::instance()->get('endDate');
|
||||
$startTime = 0;
|
||||
$endTime = time();
|
||||
$where = array();
|
||||
if(!empty($username)) $where['username'] = array('like',"%".$username."%");
|
||||
if($startDate) $startTime = strtotime($startDate);
|
||||
if($endDate) $endTime = strtotime($endDate);
|
||||
$where['control_time'] = array('between',[$startTime,$endTime]);
|
||||
$log_list = Db::name('agent_log')->where($where)->order('control_time desc')->select();
|
||||
$log_sum = Db::name('agent_log')->count();
|
||||
foreach($log_list as $k => $v){
|
||||
$v['control_time'] = date('Y-m-d H:i:s',$v['control_time']);
|
||||
if(empty($v['ip_location'])) $v['ip_location'] = "无";
|
||||
$log_list[$k] = $v;
|
||||
}
|
||||
$this->assign('log_list',$log_list);
|
||||
$this->assign('log_sum',$log_sum);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 用户登录日志
|
||||
public function user_login()
|
||||
{
|
||||
// 接收分页的条件
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get',$get);
|
||||
$this->assign('query',$query);
|
||||
|
||||
// 接收搜索参数
|
||||
$username = Request::instance()->get('username');
|
||||
$remark = Request::instance()->get('remark');
|
||||
$startDate = Request::instance()->get('startDate');
|
||||
$endDate = Request::instance()->get('endDate');
|
||||
$export = Request::instance()->get('export');
|
||||
$startTime = 0;
|
||||
$endTime = time();
|
||||
|
||||
// 拼装搜索条件
|
||||
$where = array();
|
||||
if(!empty($username)) $where['username'] = array('like',"%".$username."%");
|
||||
if(!empty($remark)) $where['remark'] = $remark;
|
||||
if($startDate) $startTime = strtotime($startDate);
|
||||
if($endDate) $endTime = strtotime($endDate);
|
||||
$where['create_time'] = array('between',[$startTime,$endTime]);
|
||||
|
||||
if($export == 1){
|
||||
$log_list = Db::name('user_log')->where($where)->order('create_time desc')->select();
|
||||
}else{
|
||||
// 查询所有的日志信息
|
||||
$log_list = Db::name('user_log')->where($where)->order('create_time desc')->paginate(10,false,array('query'=>$get));
|
||||
}
|
||||
$log_sum = Db::name('user_log')->count();
|
||||
foreach($log_list as $k => $v){
|
||||
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
|
||||
$log_list[$k] = $v;
|
||||
}
|
||||
|
||||
//导出excel列表
|
||||
if($export == 1){
|
||||
if($log_list){
|
||||
//重新组合
|
||||
$excelData = array();
|
||||
foreach($log_list AS $k => $v){
|
||||
$excelData[$k][0] = $v['username'];
|
||||
$excelData[$k][1] = $v['nickname'];
|
||||
$excelData[$k][2] = $v['ip'];
|
||||
$excelData[$k][3] = $v['ip_location'];
|
||||
$excelData[$k][4] = $v['client'];
|
||||
$excelData[$k][5] = $v['remark'];
|
||||
$excelData[$k][6] = $v['create_time'];
|
||||
}
|
||||
$title = array('账号','姓名','IP','IP所属地区','登录客户端','备注','操作时间');
|
||||
if($startDate && $endDate){
|
||||
$this->exportExcelCore($excelData, '用户登录日志-'.$startDate."-".$endDate, $title);
|
||||
}else{
|
||||
$this->exportExcelCore($excelData, '用户登录日志', $title);
|
||||
}
|
||||
exit('已导出支持列表,请不要重复刷新该页面!');
|
||||
}else{
|
||||
exit('没有可以导出的列表!');
|
||||
}
|
||||
}
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('log_list',$log_list);
|
||||
$this->assign('log_sum',$log_sum);
|
||||
return $this->fetch();
|
||||
}
|
||||
public function user_login_print(){
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$username = Request::instance()->get('username');
|
||||
$remark = Request::instance()->get('remark');
|
||||
$startDate = Request::instance()->get('startDate');
|
||||
$endDate = Request::instance()->get('endDate');
|
||||
$startTime = 0;
|
||||
$endTime = time();
|
||||
$where = array();
|
||||
if(!empty($username)) $where['username'] = array('like',"%".$username."%");
|
||||
if(!empty($remark)) $where['remark'] = $remark;
|
||||
if($startDate) $startTime = strtotime($startDate);
|
||||
if($endDate) $endTime = strtotime($endDate);
|
||||
$where['create_time'] = array('between',[$startTime,$endTime]);
|
||||
$log_list = Db::name('user_log')->where($where)->order('create_time desc')->select();
|
||||
$log_sum = Db::name('user_log')->count();
|
||||
foreach($log_list as $k => $v){
|
||||
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
|
||||
$log_list[$k] = $v;
|
||||
}
|
||||
$this->assign('log_list',$log_list);
|
||||
$this->assign('log_sum',$log_sum);
|
||||
return $this->fetch();
|
||||
}
|
||||
// 扫描用户
|
||||
public function scan_admin(){
|
||||
// 接收分页的条件
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get',$get);
|
||||
$this->assign('query',$query);
|
||||
$admin_list = Db::name('scan_account')->order('id desc')->paginate(10,false,array('query'=>$get));
|
||||
// 渲染参数和模板
|
||||
$this->assign('admin_list',$admin_list);
|
||||
return $this->fetch();
|
||||
}
|
||||
// 接口用户
|
||||
public function api_admin(){
|
||||
// 接收分页的条件
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get',$get);
|
||||
$this->assign('query',$query);
|
||||
$admin_list = Db::name('api_account')->order('id desc')->paginate(10,false,array('query'=>$get));
|
||||
// 渲染参数和模板
|
||||
$this->assign('admin_list',$admin_list);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 扫描用户添加页面
|
||||
public function scan_admin_add(){
|
||||
// 渲染参数和模板
|
||||
return $this->fetch();
|
||||
}
|
||||
// API用户添加页面
|
||||
public function api_admin_add(){
|
||||
// 渲染参数和模板
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 处理扫描用户添加
|
||||
public function do_scan_admin_add(){
|
||||
// 接收提交过来的数据
|
||||
$appid = Request::instance()->post('appid');
|
||||
$pass = Request::instance()->post('pass');
|
||||
$repass = Request::instance()->post('repass');
|
||||
$name = Request::instance()->post('name');
|
||||
$remake = Request::instance()->post('remake');
|
||||
|
||||
// 数据验证
|
||||
if( !isset($appid) && empty($appid) ){
|
||||
return json(['code'=>0,'msg'=>'用户名不能为空!']);
|
||||
}
|
||||
if( !isset($pass) && empty($pass) ){
|
||||
return json(['code'=>0,'msg'=>'密码不能为空!']);
|
||||
}
|
||||
if( !isset($repass) && empty($repass) ){
|
||||
return json(['code'=>0,'msg'=>'确认密码不能为空!']);
|
||||
}
|
||||
if( $repass != $pass ){
|
||||
return json(['code'=>0,'msg'=>'两次密码不一致!']);
|
||||
}
|
||||
if( !isset($name) && empty($name) ){
|
||||
return json(['code'=>0,'msg'=>'名称不能为空!']);
|
||||
}
|
||||
|
||||
// 检测用户名是否已经被注册
|
||||
$user = Db::name('scan_account')->where('appid',$appid)->find();
|
||||
if($user){
|
||||
return json(['code'=>0,'msg'=>'用户已存在!']);
|
||||
}
|
||||
|
||||
// 拼装数据
|
||||
$data = array();
|
||||
$data['appid'] = $appid;
|
||||
$data['appsecret'] = think_ucenter_md5($pass, UC_AUTH_KEY);
|
||||
$data['name'] = $name;
|
||||
$data['remake'] = $remake;
|
||||
$insert_id = Db::name('scan_account')->insertGetId($data);
|
||||
if($insert_id){
|
||||
// 写入管理员日志
|
||||
insertAdminLog('添加扫描用户','添加扫描用户:| ID: '.$insert_id.' | appid: '.$appid);
|
||||
return json(['code'=>1,'msg'=>'添加成功!']);
|
||||
}else{
|
||||
return json(['code'=>0,'msg'=>'添加失败!']);
|
||||
}
|
||||
}
|
||||
|
||||
// 处理API用户添加
|
||||
public function do_api_admin_add(){
|
||||
// 接收提交过来的数据
|
||||
$appid = Request::instance()->post('appid');
|
||||
$pass = Request::instance()->post('pass');
|
||||
$repass = Request::instance()->post('repass');
|
||||
$name = Request::instance()->post('name');
|
||||
|
||||
// 数据验证
|
||||
if( !isset($appid) && empty($appid) ){
|
||||
return json(['code'=>0,'msg'=>'APPID不能为空']);
|
||||
}
|
||||
if( !isset($pass) && empty($pass) ){
|
||||
return json(['code'=>0,'msg'=>'秘钥不能为空']);
|
||||
}
|
||||
if( !isset($repass) && empty($repass) ){
|
||||
return json(['code'=>0,'msg'=>'确认秘钥不能为空']);
|
||||
}
|
||||
if( $repass != $pass ){
|
||||
return json(['code'=>0,'msg'=>'两次秘钥不一致']);
|
||||
}
|
||||
if( !isset($name) && empty($name) ){
|
||||
return json(['code'=>0,'msg'=>'名称不能为空!']);
|
||||
}
|
||||
|
||||
// 检测用户名是否已经被注册
|
||||
$user = Db::name('api_account')->where('appid',$appid)->find();
|
||||
if($user){
|
||||
return json(['code'=>0,'msg'=>'APPID已存在']);
|
||||
}
|
||||
|
||||
// 拼装数据
|
||||
$data = array();
|
||||
$data['appid'] = $appid;
|
||||
$data['appsecret'] = $pass;
|
||||
$data['name'] = $name;
|
||||
$insert_id = Db::name('api_account')->insertGetId($data);
|
||||
if($insert_id){
|
||||
// 写入管理员日志
|
||||
insertAdminLog('添加扫描用户','添加API用户:| ID: '.$insert_id.' | appid: '.$appid);
|
||||
return json(['code'=>1,'msg'=>'添加成功!']);
|
||||
}else{
|
||||
return json(['code'=>0,'msg'=>'添加失败!']);
|
||||
}
|
||||
}
|
||||
|
||||
// 扫描用户编辑页面
|
||||
public function scan_admin_edit(){
|
||||
// 扫描用户
|
||||
$id = Request::instance()->get('id');
|
||||
$admin = Db::name('scan_account')->find($id);
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('admin',$admin);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// API用户编辑页面
|
||||
public function api_admin_edit(){
|
||||
// API用户
|
||||
$id = Request::instance()->get('id');
|
||||
$admin = Db::name('api_account')->find($id);
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('admin',$admin);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 处理扫描用户编辑
|
||||
public function do_scan_admin_edit(){
|
||||
if(Request::instance()->post()){
|
||||
// 接收传过来的数据
|
||||
$scan_admin_id = Request::instance()->post('scan_admin_id');
|
||||
$appid = Request::instance()->post('appid');
|
||||
$pass = Request::instance()->post('pass');
|
||||
$repass = Request::instance()->post('repass');
|
||||
$name = Request::instance()->post('name');
|
||||
$remake = Request::instance()->post('remake');
|
||||
|
||||
//数据验证
|
||||
if(empty($appid)){
|
||||
return json(['code'=>0,'msg'=>'appid不能为空!']);
|
||||
}
|
||||
if(!empty($pass) && strlen($pass) < 6){
|
||||
return json(['code'=>0,'msg'=>'密码长度不能少于6位!']);
|
||||
}
|
||||
if(!empty($pass) && $pass != $repass){
|
||||
return json(['code'=>0,'msg'=>'两次密码输入不一致!']);
|
||||
}
|
||||
|
||||
// 拼装数据
|
||||
$data = array();
|
||||
if(!empty($pass)) $data['appsecret'] = think_ucenter_md5($pass, UC_AUTH_KEY);
|
||||
$data['name'] = $name;
|
||||
$data['remake'] = $remake;
|
||||
|
||||
// 修改管理员资料
|
||||
$result = Db::name('scan_account')->where('id',$scan_admin_id)->update($data);
|
||||
if($result){
|
||||
insertAdminLog('修改扫描用户','修改扫描用户:| ID: '.$scan_admin_id.' | appid:'.$appid);
|
||||
return json(['code'=>1,'msg'=>'修改成功!']);
|
||||
}else{
|
||||
return json(['code'=>0,'msg'=>'修改失败!']);
|
||||
}
|
||||
}else{
|
||||
return json(['code'=>0,'msg'=>'操作错误!']);
|
||||
}
|
||||
}
|
||||
|
||||
// 处理API用户编辑
|
||||
public function do_api_admin_edit(){
|
||||
if(Request::instance()->post()){
|
||||
// 接收传过来的数据
|
||||
$id = Request::instance()->post('id');
|
||||
$appid = Request::instance()->post('appid');
|
||||
$pass = Request::instance()->post('pass');
|
||||
$repass = Request::instance()->post('repass');
|
||||
$name = Request::instance()->post('name');
|
||||
|
||||
//数据验证
|
||||
if(empty($appid)){
|
||||
return json(['code'=>0,'msg'=>'appid不能为空!']);
|
||||
}
|
||||
if(!empty($pass) && strlen($pass) < 6){
|
||||
return json(['code'=>0,'msg'=>'密码长度不能少于6位!']);
|
||||
}
|
||||
if(!empty($pass) && $pass != $repass){
|
||||
return json(['code'=>0,'msg'=>'两次密码输入不一致!']);
|
||||
}
|
||||
|
||||
// 拼装数据
|
||||
$data = array();
|
||||
$data['appsecret'] = $pass;
|
||||
$data['name'] = $name;
|
||||
|
||||
// 修改管理员资料
|
||||
$result = Db::name('api_account')->where('id',$id)->update($data);
|
||||
if($result){
|
||||
insertAdminLog('修改API用户','修改API用户:| ID: '.$id.' | appid:'.$appid);
|
||||
return json(['code'=>1,'msg'=>'修改成功!']);
|
||||
}else{
|
||||
return json(['code'=>0,'msg'=>'修改失败!']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 删除扫描用户
|
||||
public function scan_admin_del()
|
||||
{
|
||||
if(Request::instance()->post()){
|
||||
// 接收数据
|
||||
$scan_admin_id = Request::instance()->post('scan_admin_id');
|
||||
$scan_admin = Db::name('scan_account')->where('id',$scan_admin_id)->find();
|
||||
// 数据验证
|
||||
if(!$scan_admin){
|
||||
return json(['code'=>0,'msg'=>'用户不存在']);
|
||||
}
|
||||
|
||||
// 删除用户
|
||||
$result = Db::name('scan_account')->where('id',$scan_admin_id)->delete();
|
||||
if($result){
|
||||
insertAdminLog('删除扫描用户',"删除扫描用户: | appid: ".$scan_admin['appid']);
|
||||
return json(['code'=>1,'msg'=>'删除成功!']);
|
||||
}else{
|
||||
return json(['code'=>1,'msg'=>'删除失败!']);
|
||||
}
|
||||
}else{
|
||||
return json(['code'=>0,'msg'=>'操作错误!']);
|
||||
}
|
||||
}
|
||||
// 删除API用户
|
||||
public function api_admin_del(){
|
||||
if(Request::instance()->post()){
|
||||
// 接收数据
|
||||
$id = Request::instance()->post('id');
|
||||
// 删除用户
|
||||
$result = Db::name('api_account')->where('id',$id)->delete();
|
||||
if($result){
|
||||
insertAdminLog('删除API用户',"删除API用户: | id: ".$id);
|
||||
return json(['code'=>1,'msg'=>'删除成功!']);
|
||||
}else{
|
||||
return json(['code'=>1,'msg'=>'删除失败!']);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 更改APIStatus
|
||||
public function api_admin_status(){
|
||||
if(Request::instance()->post()){
|
||||
// 接收数据
|
||||
$id = Request::instance()->post('id');
|
||||
// 删除用户
|
||||
$find = Db::name('api_account')->where('id',$id)->find();
|
||||
if($find['status'] == 1){
|
||||
$status = 0;
|
||||
}else{
|
||||
$status = 1;
|
||||
}
|
||||
$result = Db::name('api_account')->where('id',$id)->update(array('status' => $status));
|
||||
if($result){
|
||||
insertAdminLog('更改API用户状态',"更改API用户状态: | id: ".$id);
|
||||
return json(['code'=>1,'msg'=>'更改状态成功!']);
|
||||
}else{
|
||||
return json(['code'=>1,'msg'=>'更改状态失败!']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+97
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\Session;
|
||||
use think\Controller;
|
||||
use ValidateCode\ValidateCode;
|
||||
use think\Request;
|
||||
use think\Db;
|
||||
|
||||
class Login extends Controller{
|
||||
/**
|
||||
* 登录页面
|
||||
*/
|
||||
public function index(){
|
||||
$user_info = Session::get('user_info');
|
||||
if(!empty($user_info)){
|
||||
$this->redirect('/',302);
|
||||
}
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理登录
|
||||
*/
|
||||
public function do_login(){
|
||||
if(Request::instance()->post()){
|
||||
// 接收表单提交过来的数据,做数据验证
|
||||
$admin = Request::instance()->post('username');
|
||||
$password = Request::instance()->post('password');
|
||||
$code = Request::instance()->post('code');
|
||||
if(!isset($admin) || empty($admin)){
|
||||
die(json_encode(['code'=>0,'msg'=>'用户名不能为空!']));
|
||||
}
|
||||
if(!isset($password) || empty($password)){
|
||||
die(json_encode(['code'=>0,'msg'=>'密码不能为空!']));
|
||||
}
|
||||
if(!isset($code) || empty($code)){
|
||||
die(json_encode(['code'=>0,'msg'=>'验证码不能为空!']));
|
||||
}
|
||||
|
||||
// 从session里拿到验证码,进行验证码对比
|
||||
$validate_code = Session::get('validate_code');
|
||||
if($code != $validate_code){
|
||||
die(json_encode(['code'=>0,'msg'=>'验证码错误!']));
|
||||
}
|
||||
|
||||
// 查询客户信息,判断用户名和密码是否正确
|
||||
$admin_info = Db::name('admin')->where('admin',$admin)->find();
|
||||
if(empty($admin_info)){
|
||||
die(json_encode(['code'=>0,'msg'=>'用户不存在!']));
|
||||
}
|
||||
|
||||
if(think_ucenter_md5($password,UC_AUTH_KEY) != $admin_info['password']){
|
||||
die(json_encode(['code'=>0,'msg'=>'密码错误!']));
|
||||
}
|
||||
if($admin_info['status'] != 1){
|
||||
die(json_encode(['code'=>0,'msg'=>'该账户未激活!']));
|
||||
}
|
||||
$last_login_info = Db::name('admin')->where(array('id' => $admin_info['id']))->field(['last_login_time','last_login_ip'])->find();
|
||||
Session::set('last_login_info',$last_login_info);
|
||||
|
||||
// 生成login_token用于WebSocket连接验证
|
||||
$login_token = md5($admin_info['id'] . time() . uniqid());
|
||||
Db::name('admin')->where(array('id' => $admin_info['id']))->update(array(
|
||||
'last_login_time' => time(),
|
||||
'last_login_ip' => getIP(),
|
||||
'login_token' => $login_token
|
||||
));
|
||||
|
||||
$user_info = Db::name('admin')->where('id',$admin_info['id'])->find();
|
||||
Session::set('user_info',$user_info);
|
||||
insertAdminLog('登录');
|
||||
die(json_encode(['code'=>1,'msg'=>'登录成功!']));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'操作错误!']));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 登出
|
||||
*/
|
||||
public function logout(){
|
||||
insertAdminLog('退出');
|
||||
Session::set('user_info',"");
|
||||
Session::set('last_login_info',"");
|
||||
$this->redirect('/login/index',302);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证码
|
||||
*/
|
||||
public function validateCode(){
|
||||
$validate = new ValidateCode();
|
||||
$validate->doimg();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,505 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\Db;
|
||||
use think\Request;
|
||||
|
||||
class Memo extends Common{
|
||||
// 公告列表
|
||||
public function memo(){
|
||||
// 接收分页的条件
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get',$get);
|
||||
$this->assign('query',$query);
|
||||
|
||||
// 接收搜索的条件信息
|
||||
$title = Request::instance()->get('title');
|
||||
$status = Request::instance()->get('status');
|
||||
$export = Request::instance()->get('export');
|
||||
|
||||
// 拼装查询条件
|
||||
$where = array();
|
||||
if($title) $where['title'] = array('like','%'.$title.'%');
|
||||
if($status > 0){
|
||||
// 锁定不能用0作为判断,用2代替
|
||||
if($status == 2){
|
||||
$where['status'] = 0;
|
||||
}else{
|
||||
$where['status'] = $status;
|
||||
}
|
||||
}
|
||||
|
||||
if($export == 1){
|
||||
$memo_list = Db::name('memo')->where('type', 'in', '1, 2')->where($where)->order('id desc')->select();
|
||||
}else{
|
||||
// 公告列表
|
||||
$memo_list = Db::name('memo')->where('type', 'in', '1, 2')->where($where)->order('id desc')->paginate(10,false,array('query'=>$get));
|
||||
}
|
||||
foreach($memo_list as $k => $v){
|
||||
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
|
||||
$v['table_name'] = Db::name('table')->where('id',$v['table_id'])->value('table_name');
|
||||
if($v['position'] == 1){
|
||||
$v['position'] = "投注页面";
|
||||
}
|
||||
if($v['position'] == 2){
|
||||
$v['position'] = "路单页面";
|
||||
}
|
||||
if($v['position'] == 3){
|
||||
$v['position'] = "所有页面";
|
||||
}
|
||||
$memo_list[$k] = $v;
|
||||
}
|
||||
|
||||
//导出excel列表
|
||||
if($export == 1){
|
||||
if($memo_list){
|
||||
//重新组合
|
||||
$excelData = array();
|
||||
foreach($memo_list AS $k => $v){
|
||||
$excelData[$k][0] = $v['table_name'];
|
||||
$excelData[$k][1] = $v['title'];
|
||||
$excelData[$k][2] = $v['url'];
|
||||
$excelData[$k][3] = $v['content'];
|
||||
$excelData[$k][4] = $v['remark'];
|
||||
$excelData[$k][5] = $v['position'];
|
||||
$excelData[$k][6] = $v['create_time'];
|
||||
if($v['status'] == 1){
|
||||
$excelData[$k][7] = '正常';
|
||||
}else{
|
||||
$excelData[$k][7] = '锁定中';
|
||||
}
|
||||
}
|
||||
$title = array('桌子名称','标题','链接地址','内容','备注','显示位置','创建时间','状态');
|
||||
$this->exportExcelCore($excelData, '公告列表', $title);
|
||||
|
||||
exit('已导出支持列表,请不要重复刷新该页面!');
|
||||
}else{
|
||||
exit('没有可以导出的列表!');
|
||||
}
|
||||
}
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('memo_list',$memo_list);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 活动列表
|
||||
public function activity(){
|
||||
// 接收分页的条件
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get',$get);
|
||||
$this->assign('query',$query);
|
||||
|
||||
// 接收搜索的条件信息
|
||||
$title = Request::instance()->get('title');
|
||||
$status = Request::instance()->get('status');
|
||||
$export = Request::instance()->get('export');
|
||||
|
||||
// 拼装查询条件
|
||||
$where = array();
|
||||
if($title) $where['title'] = array('like','%'.$title.'%');
|
||||
if($status > 0){
|
||||
// 锁定不能用0作为判断,用2代替
|
||||
if($status == 2){
|
||||
$where['status'] = 0;
|
||||
}else{
|
||||
$where['status'] = $status;
|
||||
}
|
||||
}
|
||||
if($export == 1){
|
||||
$memo_list = Db::name('memo')->where('type',2)->where($where)->order('id desc')->select();
|
||||
}else{
|
||||
// 活动列表
|
||||
$memo_list = Db::name('memo')->where('type',2)->where($where)->order('id desc')->paginate(10,false,array('query'=>$get));
|
||||
}
|
||||
foreach($memo_list as $k => $v){
|
||||
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
|
||||
$v['table_name'] = Db::name('table')->where('id',$v['table_id'])->value('table_name');
|
||||
if($v['position'] == 1){
|
||||
$v['position'] = "投注页面";
|
||||
}
|
||||
if($v['position'] == 2){
|
||||
$v['position'] = "路单页面";
|
||||
}
|
||||
if($v['position'] == 3){
|
||||
$v['position'] = "所有页面";
|
||||
}
|
||||
$memo_list[$k] = $v;
|
||||
}
|
||||
|
||||
//导出excel列表
|
||||
if($export == 1){
|
||||
if($memo_list){
|
||||
//重新组合
|
||||
$excelData = array();
|
||||
foreach($memo_list AS $k => $v){
|
||||
$excelData[$k][0] = $v['table_name'];
|
||||
$excelData[$k][1] = $v['title'];
|
||||
$excelData[$k][2] = $v['url'];
|
||||
$excelData[$k][3] = $v['content'];
|
||||
$excelData[$k][4] = $v['remark'];
|
||||
$excelData[$k][5] = $v['position'];
|
||||
$excelData[$k][6] = $v['create_time'];
|
||||
if($v['status'] == 1){
|
||||
$excelData[$k][7] = '正常';
|
||||
}else{
|
||||
$excelData[$k][7] = '锁定中';
|
||||
}
|
||||
}
|
||||
$title = array('桌子名称','标题','链接地址','内容','备注','显示位置','创建时间','状态');
|
||||
$this->exportExcelCore($excelData, '活动列表', $title);
|
||||
|
||||
exit('已导出支持列表,请不要重复刷新该页面!');
|
||||
}else{
|
||||
exit('没有可以导出的列表!');
|
||||
}
|
||||
}
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('memo_list',$memo_list);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 添加公告
|
||||
public function memo_add(){
|
||||
$table_list = Db::name('table')->select();
|
||||
$this->assign('table_list',$table_list);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 添加活动
|
||||
public function activity_add(){
|
||||
$table_list = Db::name('table')->select();
|
||||
$this->assign('table_list',$table_list);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 处理添加公告和添加活动
|
||||
public function do_memo_add()
|
||||
{
|
||||
if(Request::instance()->post()){
|
||||
|
||||
// 接收提交过来的数据
|
||||
//$table_id = Request::instance()->post('table_id');
|
||||
$title = Request::instance()->post('title');
|
||||
//$url = Request::instance()->post('url');
|
||||
//$content = Request::instance()->post('content');
|
||||
//$position = Request::instance()->post('position');
|
||||
//$remark = Request::instance()->post('remark');
|
||||
$type = intval(Request::instance()->post('type')); //区分公告和活动 1:公告 2:活动
|
||||
if( !isset($title) && empty($title) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'标题不能为空!']));
|
||||
}
|
||||
// 数据验证
|
||||
/*
|
||||
if($table_id == -1 || $table_id == ''){
|
||||
die(json_encode(['code'=>0,'msg'=>'请选择桌子!']));
|
||||
}
|
||||
if( !isset($url) && empty($url) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'链接不能为空!']));
|
||||
}
|
||||
if( !isset($content) && empty($content) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'内容不能为空!']));
|
||||
}
|
||||
if($position == -1 || $position == ''){
|
||||
die(json_encode(['code'=>0,'msg'=>'请选择公告位置!']));
|
||||
}
|
||||
if( !isset($remark) && empty($remark) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'备注不能为空!']));
|
||||
}
|
||||
*/
|
||||
|
||||
// 拼装数据
|
||||
$data = array();
|
||||
$data['type'] = $type;
|
||||
$data['title'] = $title;
|
||||
/*
|
||||
$data['table_id'] = $table_id;
|
||||
$data['url'] = $url;
|
||||
$data['content'] = $content;
|
||||
$data['position'] = $position;
|
||||
$data['remark'] = $remark;
|
||||
$data['status'] = 1;
|
||||
*/
|
||||
$data['create_time'] = time();
|
||||
/*
|
||||
if($data['table_id'] == 'all'){
|
||||
$all_table = Db::name('table')->select();
|
||||
foreach($all_table as $k => $v){
|
||||
$data['table_id'] = $v['id'];
|
||||
$insert_id = Db::name('memo')->insertGetId($data);
|
||||
if(!$insert_id){
|
||||
die(json_encode(['code'=>0,'msg'=>$v['table_name'].'添加失败!']));
|
||||
}
|
||||
// 写入管理员日志
|
||||
if($type == 1){
|
||||
insertAdminLog('添加公告','添加公告:| ID: '.$insert_id.' | 标题: '.$title);
|
||||
}elseif($type == 2){
|
||||
insertAdminLog('添加活动','添加活动:| ID: '.$insert_id.' | 标题: '.$title);
|
||||
}
|
||||
}
|
||||
|
||||
}else if($data['table_id'] == 'all_baccarat'){
|
||||
$all_table = Db::name('table')->where('game_id',1)->select();
|
||||
foreach($all_table as $k => $v){
|
||||
$data['table_id'] = $v['id'];
|
||||
$insert_id = Db::name('memo')->insertGetId($data);
|
||||
if(!$insert_id){
|
||||
die(json_encode(['code'=>0,'msg'=>$v['table_name'].'添加失败!']));
|
||||
}
|
||||
// 写入管理员日志
|
||||
if($type == 1){
|
||||
insertAdminLog('添加公告','添加公告:| ID: '.$insert_id.' | 标题: '.$title);
|
||||
}elseif($type == 2){
|
||||
insertAdminLog('添加活动','添加活动:| ID: '.$insert_id.' | 标题: '.$title);
|
||||
}
|
||||
}
|
||||
}else if($data['table_id'] == 'all_dt'){
|
||||
$all_table = Db::name('table')->where('game_id',2)->select();
|
||||
foreach($all_table as $k => $v){
|
||||
$data['table_id'] = $v['id'];
|
||||
$insert_id = Db::name('memo')->insertGetId($data);
|
||||
if(!$insert_id){
|
||||
die(json_encode(['code'=>0,'msg'=>$v['table_name'].'添加失败!']));
|
||||
}
|
||||
// 写入管理员日志
|
||||
if($type == 1){
|
||||
insertAdminLog('添加公告','添加公告:| ID: '.$insert_id.' | 标题: '.$title);
|
||||
}elseif($type == 2){
|
||||
insertAdminLog('添加活动','添加活动:| ID: '.$insert_id.' | 标题: '.$title);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
*/
|
||||
$insert_id = Db::name('memo')->insertGetId($data);
|
||||
if(!$insert_id){
|
||||
die(json_encode(['code'=>0,'msg'=>'添加失败!']));
|
||||
}
|
||||
// 写入管理员日志
|
||||
if($type == 1){
|
||||
insertAdminLog('添加公告','添加公告:| ID: '.$insert_id.' | 标题: '.$title);
|
||||
}elseif($type == 2){
|
||||
insertAdminLog('添加活动','添加活动:| ID: '.$insert_id.' | 标题: '.$title);
|
||||
}
|
||||
die(json_encode(['code'=>1,'msg'=>'添加成功!']));
|
||||
/*
|
||||
}
|
||||
|
||||
*/
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'操作错误!']));
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑公告
|
||||
public function memo_edit()
|
||||
{
|
||||
// 接收代理ID,查询代理信息
|
||||
$id = Request::instance()->get('id');
|
||||
$memo = Db::name('memo')->find($id);
|
||||
$table = Db::name('table')->find($memo['table_id']);
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('memo',$memo);
|
||||
$this->assign('table',$table);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 编辑活动
|
||||
public function activity_edit()
|
||||
{
|
||||
// 接收代理ID,查询代理信息
|
||||
$id = Request::instance()->get('id');
|
||||
$memo = Db::name('memo')->find($id);
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('memo',$memo);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 处理修改公告和修改活动
|
||||
public function do_memo_edit()
|
||||
{
|
||||
if(Request::instance()->post()){
|
||||
|
||||
// 接收提交过来的数据
|
||||
$id = intval(Request::instance()->post('id'));
|
||||
$title = Request::instance()->post('title');
|
||||
/*
|
||||
$url = Request::instance()->post('url');
|
||||
$content = Request::instance()->post('content');
|
||||
$remark = Request::instance()->post('remark');
|
||||
$position = Request::instance()->post('position');
|
||||
*/
|
||||
$type = Request::instance()->post('type'); //区分公告和活动 1:公告 2:活动
|
||||
|
||||
// 数据验证
|
||||
if( !isset($title) && empty($title) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'标题不能为空!']));
|
||||
}
|
||||
/*
|
||||
if( !isset($content) && empty($content) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'内容不能为空!']));
|
||||
}
|
||||
*/
|
||||
|
||||
// 拼装数据
|
||||
$data = array();
|
||||
$data['type'] = $type;
|
||||
$data['title'] = $title;
|
||||
/*
|
||||
$data['url'] = $url;
|
||||
$data['content'] = $content;
|
||||
$data['remark'] = $remark;
|
||||
$data['position'] = $position;
|
||||
$data['status'] = 1;
|
||||
*/
|
||||
$data['create_time'] = time();
|
||||
$insert_id = Db::name('memo')->where('id',$id)->update($data);
|
||||
if($insert_id){
|
||||
// 写入管理员日志
|
||||
if($type == 1){
|
||||
insertAdminLog('修改公告','修改公告:| ID: '.$insert_id.' | 标题: '.$title);
|
||||
}elseif($type == 2){
|
||||
insertAdminLog('修改活动','修改活动:| ID: '.$insert_id.' | 标题: '.$title);
|
||||
}
|
||||
|
||||
die(json_encode(['code'=>1,'msg'=>'修改成功!']));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'修改失败!']));
|
||||
}
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'操作错误!']));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态(锁定和解锁)
|
||||
*/
|
||||
public function change_status()
|
||||
{
|
||||
if(Request::instance()->post()){
|
||||
// 接收传过来的数据
|
||||
$id = Request::instance()->post('id');
|
||||
$status = Request::instance()->post('status');
|
||||
$type = Request::instance()->post('type');
|
||||
|
||||
// 数据验证
|
||||
if( !isset($id) && empty($id) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'用户不能为空!']));
|
||||
}
|
||||
if( !isset($status) && empty($status) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'状态不能为空!']));
|
||||
}
|
||||
|
||||
// 修改用户状态
|
||||
$result = Db::name('memo')->where('id',$id)->update(['status'=>$status]);
|
||||
if($status == 1) $msg = "解锁";
|
||||
if($status == 0) $msg = "锁定";
|
||||
if($type == 1) $type_msg = "公告";
|
||||
if($type == 2) $type_msg = "活动";
|
||||
if($result){
|
||||
insertAdminLog($msg.$type_msg,$msg.$type_msg.": | ID: ".$id);
|
||||
die(json_encode(['code'=>1,'msg'=>$msg.'成功!']));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>$msg.'失败!']));
|
||||
}
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'操作错误!']));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除公告或者活动
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
if(Request::instance()->post()){
|
||||
// 接收数据
|
||||
$id = Request::instance()->post('id');
|
||||
$type = Request::instance()->post('type');
|
||||
|
||||
// 删除公告或者活动
|
||||
$result = Db::name('memo')->delete($id);
|
||||
if($result){
|
||||
if($type == 1) $type_msg = "公告";
|
||||
if($type == 2) $type_msg = "活动";
|
||||
insertAdminLog('删除'.$type_msg,"删除".$type_msg.": | ID: ".$id);
|
||||
die(json_encode(['code'=>1,'msg'=>'删除成功!']));
|
||||
}else{
|
||||
die(json_encode(['code'=>1,'msg'=>'删除失败!']));
|
||||
}
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'操作错误!']));
|
||||
}
|
||||
}
|
||||
public function memo_print(){
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$title = Request::instance()->get('title');
|
||||
$status = Request::instance()->get('status');
|
||||
$where = array();
|
||||
if($title) $where['title'] = array('like','%'.$title.'%');
|
||||
if($status > 0){
|
||||
// 锁定不能用0作为判断,用2代替
|
||||
if($status == 2){
|
||||
$where['status'] = 0;
|
||||
}else{
|
||||
$where['status'] = $status;
|
||||
}
|
||||
}
|
||||
$memo_list = Db::name('memo')->where('type',1)->where($where)->order('id desc')->select();
|
||||
foreach($memo_list as $k => $v){
|
||||
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
|
||||
$v['table_name'] = Db::name('table')->where('id',$v['table_id'])->value('table_name');
|
||||
if($v['position'] == 1){
|
||||
$v['position'] = "投注页面";
|
||||
}
|
||||
if($v['position'] == 2){
|
||||
$v['position'] = "路单页面";
|
||||
}
|
||||
if($v['position'] == 3){
|
||||
$v['position'] = "所有页面";
|
||||
}
|
||||
$memo_list[$k] = $v;
|
||||
}
|
||||
$this->assign('memo_list',$memo_list);
|
||||
return $this->fetch();
|
||||
}
|
||||
public function activity_print(){
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$title = Request::instance()->get('title');
|
||||
$status = Request::instance()->get('status');
|
||||
$where = array();
|
||||
if($title) $where['title'] = array('like','%'.$title.'%');
|
||||
if($status > 0){
|
||||
// 锁定不能用0作为判断,用2代替
|
||||
if($status == 2){
|
||||
$where['status'] = 0;
|
||||
}else{
|
||||
$where['status'] = $status;
|
||||
}
|
||||
}
|
||||
$memo_list = Db::name('memo')->where('type',2)->where($where)->order('id desc')->select();
|
||||
foreach($memo_list as $k => $v){
|
||||
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
|
||||
$v['table_name'] = Db::name('table')->where('id',$v['table_id'])->value('table_name');
|
||||
if($v['position'] == 1){
|
||||
$v['position'] = "投注页面";
|
||||
}
|
||||
if($v['position'] == 2){
|
||||
$v['position'] = "路单页面";
|
||||
}
|
||||
if($v['position'] == 3){
|
||||
$v['position'] = "所有页面";
|
||||
}
|
||||
$memo_list[$k] = $v;
|
||||
}
|
||||
$this->assign('memo_list',$memo_list);
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
Executable
+2835
File diff suppressed because it is too large
Load Diff
Executable
+1715
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,596 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\Db;
|
||||
use think\Request;
|
||||
use think\Session;
|
||||
|
||||
class Recharge extends Common{
|
||||
/**
|
||||
* 代理列表
|
||||
*/
|
||||
public function index(){
|
||||
// 接收分页的条件
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get',$get);
|
||||
$this->assign('query',$query);
|
||||
$recharge_list = Db::name('receivables')->where('receivables_type',1)->where('type',1)->order('id desc')->paginate(10,false,array('query'=>$get));
|
||||
foreach($recharge_list as $k => $v){
|
||||
$v['create_time'] = date("Y-m-d H:i",$v['create_time']);
|
||||
if($v['status'] == 1){
|
||||
$v['is_use'] = '使用中';
|
||||
}elseif($v['status'] == 0){
|
||||
$v['is_use'] = '禁用中';
|
||||
}
|
||||
$recharge_list[$k] = $v;
|
||||
}
|
||||
// 渲染变量和模板
|
||||
$this->assign('recharge_list',$recharge_list);
|
||||
$this->assign('query',$query);
|
||||
return $this->fetch();
|
||||
}
|
||||
public function do_add_bank(){
|
||||
if(Request::instance()->post()){
|
||||
// 获取管理员信息
|
||||
$user_info = Session::get('user_info');
|
||||
|
||||
// 接收提交过来的数据
|
||||
$receivables_name = Request::instance()->post('receivables_name');
|
||||
$receivables_bank = Request::instance()->post('receivables_bank');
|
||||
$receivables_cardnum = Request::instance()->post('receivables_cardnum');
|
||||
$is_use = Request::instance()->post('is_use');
|
||||
// 数据验证
|
||||
if( !isset($receivables_name) && empty($receivables_name) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'收款人姓名不能为空!']));
|
||||
}
|
||||
if( !isset($receivables_bank) && empty($receivables_bank) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'收款人银行不能为空!']));
|
||||
}
|
||||
if( !isset($receivables_cardnum) && empty($receivables_cardnum) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'收款人卡号不能为空!']));
|
||||
}
|
||||
if( !isset($is_use) && empty($is_use) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'收款银行卡状态不能为空!']));
|
||||
}
|
||||
|
||||
// 拼装数据
|
||||
$data = array();
|
||||
$data['receivables_type'] = 1;
|
||||
$data['receivables_name'] = $receivables_name;
|
||||
$data['receivables_bank'] = $receivables_bank;
|
||||
$data['receivables_bank_number'] = $receivables_cardnum;
|
||||
$data['status'] = $is_use;
|
||||
$data['create_time'] = time();
|
||||
$data['type'] = 1;
|
||||
|
||||
$insert_id = Db::name('receivables')->insertGetId($data);
|
||||
if($insert_id){
|
||||
// 写入管理员日志
|
||||
insertAdminLog('添加收款银行卡','添加收款银行卡:| ID: '.$insert_id.' | 收款人: '.$receivables_name);
|
||||
die(json_encode(['code'=>1,'msg'=>'添加成功!']));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'添加失败!']));
|
||||
}
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'操作错误!']));
|
||||
}
|
||||
}
|
||||
public function do_edit_bank(){
|
||||
if(Request::instance()->post()){
|
||||
// 获取管理员信息
|
||||
$user_info = Session::get('user_info');
|
||||
|
||||
// 接收提交过来的数据
|
||||
$id = Request::instance()->post('receivables_id');
|
||||
$receivables_name = Request::instance()->post('receivables_name');
|
||||
$receivables_bank = Request::instance()->post('receivables_bank');
|
||||
$receivables_cardnum = Request::instance()->post('receivables_cardnum');
|
||||
$is_use = Request::instance()->post('is_use');
|
||||
// 数据验证
|
||||
if( !isset($receivables_name) && empty($receivables_name) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'收款人姓名不能为空!']));
|
||||
}
|
||||
if( !isset($receivables_bank) && empty($receivables_bank) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'收款人银行不能为空!']));
|
||||
}
|
||||
if( !isset($receivables_cardnum) && empty($receivables_cardnum) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'收款人卡号不能为空!']));
|
||||
}
|
||||
if( !isset($is_use) && empty($is_use) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'收款银行卡状态不能为空!']));
|
||||
}
|
||||
|
||||
// 拼装数据
|
||||
$data = array();
|
||||
$data['receivables_type'] = 1;
|
||||
$data['receivables_name'] = $receivables_name;
|
||||
$data['receivables_bank'] = $receivables_bank;
|
||||
$data['receivables_bank_number'] = $receivables_cardnum;
|
||||
$data['status'] = $is_use;
|
||||
|
||||
$insert_id = Db::name('receivables')->where('id',$id)->update($data);
|
||||
if($insert_id){
|
||||
// 写入管理员日志
|
||||
insertAdminLog('修改收款银行卡','修改收款银行卡:| ID: '.$insert_id.' | 收款人: '.$receivables_name);
|
||||
die(json_encode(['code'=>1,'msg'=>'修改成功!']));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'修改失败!']));
|
||||
}
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'操作错误!']));
|
||||
}
|
||||
}
|
||||
public function qr_code(){
|
||||
// 接收分页的条件
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get',$get);
|
||||
$this->assign('query',$query);
|
||||
$recharge_list = Db::name('receivables')->wherein('receivables_type','2,3')->where('type',1)->order('id desc')->paginate(10,false,array('query'=>$get));
|
||||
foreach($recharge_list as $k => $v){
|
||||
$v['create_time'] = date("Y-m-d H:i",$v['create_time']);
|
||||
if($v['status'] == 1){
|
||||
$v['is_use'] = '使用中';
|
||||
}elseif($v['status'] == 0){
|
||||
$v['is_use'] = '禁用中';
|
||||
}
|
||||
if($v['receivables_type'] == 2){
|
||||
$v['receivables_type_word'] = '微信';
|
||||
}elseif($v['receivables_type'] == 3){
|
||||
$v['receivables_type_word'] = '支付宝';
|
||||
}
|
||||
$recharge_list[$k] = $v;
|
||||
}
|
||||
// 渲染变量和模板
|
||||
$this->assign('recharge_list',$recharge_list);
|
||||
$this->assign('query',$query);
|
||||
return $this->fetch();
|
||||
}
|
||||
public function deposit() {
|
||||
if ($this->request->isPost() && $this->request->param('action') != 'upload') {
|
||||
$base64 = $this->request->param('base64');
|
||||
$base64 = str_replace(' ', '+', $base64);
|
||||
if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $base64, $result)) {
|
||||
|
||||
$type = $result[2];
|
||||
if (in_array($type,array('pjpeg','jpeg','jpg','gif','bmp','png'))) {
|
||||
$path = APP_PATH . '../public/static/admin/uploads/';
|
||||
|
||||
$fileName = time() . '.' . $type;
|
||||
$relPathFile = '/static/admin/uploads/' . $fileName;
|
||||
$absPathFile = $path . $fileName;
|
||||
|
||||
if (file_put_contents($absPathFile, base64_decode(str_replace($result[1], '', $base64)))) {
|
||||
//$this->success('上传成功');
|
||||
$this->success($relPathFile);
|
||||
} else {
|
||||
$this->error('上传失败');
|
||||
}
|
||||
} else {
|
||||
$this->error('非法操作,类型不允许!');
|
||||
}
|
||||
} else {
|
||||
$this->error('网络错误,请稍后再试');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public function do_add_code(){
|
||||
if(Request::instance()->post()){
|
||||
// 获取管理员信息
|
||||
$user_info = Session::get('user_info');
|
||||
|
||||
// 接收提交过来的数据
|
||||
$receivables_name = Request::instance()->post('receivables_name');
|
||||
$receivables_qr_code = Request::instance()->post('img_url');
|
||||
$code_type = Request::instance()->post('code_type');
|
||||
$is_use = Request::instance()->post('is_use');
|
||||
// 数据验证
|
||||
if( !isset($receivables_name) && empty($receivables_name) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'收款人姓名不能为空!']));
|
||||
}
|
||||
if( !isset($receivables_qr_code) && empty($receivables_qr_code) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'收款二维码不能为空!']));
|
||||
}
|
||||
if( !isset($code_type) && empty($code_type) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'收款二维码类型不能为空!']));
|
||||
}
|
||||
if( !isset($is_use) && empty($is_use) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'收款二维码状态不能为空!']));
|
||||
}
|
||||
|
||||
// 拼装数据
|
||||
$data = array();
|
||||
if($code_type == 2){
|
||||
$data['receivables_type'] = 2;
|
||||
}elseif($code_type == 3){
|
||||
$data['receivables_type'] = 3;
|
||||
}
|
||||
$data['receivables_name'] = $receivables_name;
|
||||
$data['receivables_qr_code'] = $receivables_qr_code;
|
||||
$data['status'] = $is_use;
|
||||
$data['create_time'] = time();
|
||||
$data['type'] = 1;
|
||||
|
||||
if($is_use == 1){
|
||||
Db::name('receivables')->where('receivables_type',$code_type)->update(['status' => 0]);
|
||||
}
|
||||
$insert_id = Db::name('receivables')->insertGetId($data);
|
||||
if($insert_id){
|
||||
// 写入管理员日志
|
||||
insertAdminLog('添加收款二维码','添加收款二维码:| ID: '.$insert_id.' | 收款账号: '.$receivables_name);
|
||||
die(json_encode(['code'=>1,'msg'=>'添加成功!']));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'添加失败!']));
|
||||
}
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'操作错误!']));
|
||||
}
|
||||
}
|
||||
public function do_edit_code(){
|
||||
if(Request::instance()->post()){
|
||||
// 获取管理员信息
|
||||
$user_info = Session::get('user_info');
|
||||
|
||||
// 接收提交过来的数据
|
||||
$id = Request::instance()->post('receivables_id');
|
||||
$receivables_name = Request::instance()->post('receivables_name');
|
||||
$receivables_type = Request::instance()->post('code_type');
|
||||
$is_use = Request::instance()->post('is_use');
|
||||
// 数据验证
|
||||
if( !isset($receivables_name) && empty($receivables_name) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'收款账号不能为空!']));
|
||||
}
|
||||
if( !isset($receivables_type) && empty($receivables_type) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'收款二维码类型不能为空!']));
|
||||
}
|
||||
if( !isset($is_use) && empty($is_use) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'收款银行卡状态不能为空!']));
|
||||
}
|
||||
|
||||
// 拼装数据
|
||||
$data = array();
|
||||
$data['receivables_type'] = $receivables_type;
|
||||
$data['receivables_name'] = $receivables_name;
|
||||
$data['status'] = $is_use;
|
||||
if($is_use == 1){
|
||||
Db::name('receivables')->where('receivables_type',$receivables_type)->update(['status' => 0]);
|
||||
}
|
||||
$insert_id = Db::name('receivables')->where('id',$id)->update($data);
|
||||
if($insert_id){
|
||||
// 写入管理员日志
|
||||
insertAdminLog('修改收款二维码','修改收款二维码:| ID: '.$insert_id.' | 收款账号: '.$receivables_name);
|
||||
die(json_encode(['code'=>1,'msg'=>'修改成功!']));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'修改失败!']));
|
||||
}
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'操作错误!']));
|
||||
}
|
||||
}
|
||||
public function recharge_record(){
|
||||
Session::set('allowSubmit',"YES");
|
||||
// 接收分页的条件
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get',$get);
|
||||
$this->assign('query',$query);
|
||||
// 接收搜索的条件信息
|
||||
$username = trim(Request::instance()->get('username'));
|
||||
$export = Request::instance()->get('export');
|
||||
|
||||
// 拼装搜索条件
|
||||
$where = array();
|
||||
if(!empty($username)) $where['username'] = $username;
|
||||
$where['record_type'] = 1;
|
||||
if($export == 1){
|
||||
$recharge_list = Db::name('receivables_record')->where($where)->order('id desc')->select();
|
||||
}else{
|
||||
//获取所有代理信息
|
||||
$recharge_list = Db::name('receivables_record')->where($where)->order('id desc')->paginate(10,false,array('query'=>$get));
|
||||
}
|
||||
foreach($recharge_list as $k => $v){
|
||||
$v['create_time'] = date("Y-m-d H:i",$v['create_time']);
|
||||
if($v['recharge_type'] == 1){
|
||||
$v['recharge_type'] = '银行卡充值';
|
||||
}elseif($v['recharge_type'] == 2){
|
||||
$v['recharge_type'] = '微信充值';
|
||||
}elseif($v['recharge_type'] == 3){
|
||||
$v['recharge_type'] = '支付宝充值';
|
||||
}
|
||||
if(!$v['recharge_bank']){
|
||||
$v['recharge_bank'] = '-';
|
||||
}
|
||||
if(!$v['recharge_cardnumber']){
|
||||
$v['recharge_cardnumber'] = '-';
|
||||
}
|
||||
$v['receivables_id'] = $v['recharge_type'].'-'.$v['receivables_id'];
|
||||
$recharge_list[$k] = $v;
|
||||
}
|
||||
//导出excel列表
|
||||
if($export == 1){
|
||||
if($recharge_list){
|
||||
//重新组合
|
||||
$excelData = array();
|
||||
foreach($recharge_list AS $k => $v){
|
||||
$excelData[$k][0] = $v['username'];
|
||||
$excelData[$k][1] = $v['recharge_type'];
|
||||
$excelData[$k][2] = $v['receivables_id'];
|
||||
$excelData[$k][3] = $v['recharge_name'];
|
||||
$excelData[$k][4] = $v['recharge_bank'];
|
||||
$excelData[$k][5] = $v['recharge_cardnumber'];
|
||||
$excelData[$k][6] = $v['recharge_money'];
|
||||
$excelData[$k][7] = $v['create_time'];
|
||||
if($v['status'] == 0){
|
||||
$excelData[$k][8] = '未充值';
|
||||
}else{
|
||||
$excelData[$k][8] = '已充值';
|
||||
}
|
||||
$excelData[$k][9] = $v['controller_admin'];
|
||||
}
|
||||
$title = array('用户名','充值类型','收款方式ID','充值着账号/姓名','充值银行','充值银行账户','充值金额','创建时间','状态','操作员');
|
||||
$this->exportExcelCore($excelData, '充值列表', $title);
|
||||
exit('已导出支持列表,请不要重复刷新该页面!');
|
||||
}else{
|
||||
exit('没有可以导出的列表!');
|
||||
}
|
||||
}
|
||||
// 渲染变量和模板
|
||||
$this->assign('recharge_list',$recharge_list);
|
||||
$this->assign('query',$query);
|
||||
return $this->fetch();
|
||||
}
|
||||
public function deal_recharge(){
|
||||
if(Request::instance()->post()){
|
||||
// 接收数据
|
||||
$id = Request::instance()->post('recharge_id');
|
||||
|
||||
// 数据验证
|
||||
if(!$id){
|
||||
die(json_encode(['code'=>0,'msg'=>'充值记录不存在']));
|
||||
}
|
||||
$user_info = Session::get('user_info');
|
||||
$result = Db::name('receivables_record')->where('id',$id)->update(array('status' => 1,'controller_admin'=>$user_info['admin']));
|
||||
if($result){
|
||||
insertAdminLog('处理充值',"处理充值 | 订单ID: ".$id);
|
||||
die(json_encode(['code'=>1,'msg'=>'充值成功!']));
|
||||
}else{
|
||||
die(json_encode(['code'=>1,'msg'=>'充值失败!']));
|
||||
}
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'操作错误!']));
|
||||
}
|
||||
}
|
||||
public function withdrawal_record(){
|
||||
// 接收分页的条件
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get',$get);
|
||||
$this->assign('query',$query);
|
||||
// 接收搜索的条件信息
|
||||
$username = trim(Request::instance()->get('username'));
|
||||
$export = Request::instance()->get('export');
|
||||
|
||||
// 拼装搜索条件
|
||||
$where = array();
|
||||
if(!empty($username)) $where['username'] = $username;
|
||||
$where['record_type'] = 2;
|
||||
if($export == 1){
|
||||
$withdrawal_list = Db::name('receivables_record')->where($where)->order('id desc')->select();
|
||||
}else{
|
||||
//获取所有代理信息
|
||||
$withdrawal_list = Db::name('receivables_record')->where($where)->order('id desc')->paginate(10,false,array('query'=>$get));
|
||||
}
|
||||
foreach($withdrawal_list as $k => $v){
|
||||
$v['create_time'] = date("Y-m-d H:i",$v['create_time']);
|
||||
$withdrawal_list[$k] = $v;
|
||||
}
|
||||
//导出excel列表
|
||||
if($export == 1){
|
||||
if($withdrawal_list){
|
||||
//重新组合
|
||||
$excelData = array();
|
||||
foreach($withdrawal_list AS $k => $v){
|
||||
$excelData[$k][0] = $v['username'];
|
||||
$excelData[$k][1] = $v['recharge_bank'];
|
||||
$excelData[$k][2] = $v['recharge_bank_branch'];
|
||||
$excelData[$k][3] = $v['recharge_cardnumber'];
|
||||
$excelData[$k][4] = $v['recharge_money'];
|
||||
$excelData[$k][5] = $v['create_time'];
|
||||
if($v['status'] == 0){
|
||||
$excelData[$k][6] = '未提现';
|
||||
}else{
|
||||
$excelData[$k][6] = '已提现';
|
||||
}
|
||||
$excelData[$k][7] = $v['controller_admin'];
|
||||
}
|
||||
$title = array('用户名','提现银行','提现银行支行','提现银行账户','提现金额','创建时间','状态','操作员');
|
||||
$this->exportExcelCore($excelData, '提现列表', $title);
|
||||
exit('已导出支持列表,请不要重复刷新该页面!');
|
||||
}else{
|
||||
exit('没有可以导出的列表!');
|
||||
}
|
||||
}
|
||||
// 渲染变量和模板
|
||||
$this->assign('withdrawal_list',$withdrawal_list);
|
||||
$this->assign('query',$query);
|
||||
return $this->fetch();
|
||||
}
|
||||
public function deal_withdrawal(){
|
||||
if(Request::instance()->post()){
|
||||
$user_info = Session::get('user_info');
|
||||
// 接收数据
|
||||
$id = Request::instance()->post('recharge_id');
|
||||
// 数据验证
|
||||
$receivables_record = Db::name('receivables_record')->where(array('id' => $id, 'record_type' => 2))->find();
|
||||
if(!$receivables_record){
|
||||
die(json_encode(['code'=>0,'msg'=>'提现记录不存在']));
|
||||
}
|
||||
if($receivables_record['status'] > 0){
|
||||
die(json_encode(['code'=>0,'msg'=>'该记录已经处理过了']));
|
||||
}
|
||||
$user = Db::name('user')->where(array('id' => $receivables_record['user_id'], 'status' => 1, 'is_delete' => 0, 'agent' => 0))->find();
|
||||
if(!$user){
|
||||
die(json_encode(['code'=>0,'msg'=>'没找到相关会员信息']));
|
||||
}
|
||||
$zdlIdArr = explode(',',$user['agent_parent_id_path']);
|
||||
$zdlId = $zdlIdArr[0];
|
||||
$zdl = Db::name('user')->where(array('id' => $zdlId, 'status' => 1, 'is_delete' => 0, 'agent' => 1))->find();
|
||||
if(!$zdl){
|
||||
die(json_encode(['code'=>0,'msg'=>'所属总代理账号异常,暂不能提现']));
|
||||
}
|
||||
//防止重复提交
|
||||
$allowSubmit = Session::get('allowSubmit');
|
||||
if($allowSubmit == 'YES'){
|
||||
Session::delete('allowSubmit');
|
||||
}else{
|
||||
Session::delete('allowSubmit');
|
||||
return json(array('code' => 0, 'msg' => "请勿重复提交"));
|
||||
}
|
||||
//插入上分表并增加余分 总代理
|
||||
$recharge = array();
|
||||
$recharge['type'] = 5;
|
||||
$recharge['amount'] = $receivables_record['recharge_money'];
|
||||
$recharge['mode'] = 1;
|
||||
$recharge['agent_or_admin'] = 3;
|
||||
$recharge['user_id'] = $zdl['id'];
|
||||
$recharge['user_type'] = $zdl['agent'];
|
||||
$recharge['user_agent_level'] = 0;
|
||||
$recharge['username_for'] = $zdl['username'];
|
||||
$recharge['nickname_for'] = $zdl['nickname'];
|
||||
$recharge['user_parent_id'] = $zdl['agent_parent_id'];
|
||||
$recharge['admin_id'] = $user_info['id'];
|
||||
$recharge['admin_user_name'] = $user_info['admin'];
|
||||
$recharge['create_time'] = time();
|
||||
$recharge['old_money'] = $zdl['money'];
|
||||
$recharge['new_money'] = $zdl['money'] + $receivables_record['recharge_money'];
|
||||
$recharge['controller_system'] = 3;
|
||||
$recharge['remake'] = '总后台操作允许玩家提现,提现金额加到所属总代余额上';
|
||||
Db::name('recharge')->insert($recharge);
|
||||
//插入上分表 记录玩家余分变动
|
||||
$rechargeUser = array();
|
||||
$rechargeUser['type'] = 5;
|
||||
$rechargeUser['amount'] = $receivables_record['recharge_money'];
|
||||
$rechargeUser['mode'] = 2;
|
||||
$rechargeUser['agent_or_admin'] = 3;
|
||||
$rechargeUser['controller_id'] = $zdl['id'];
|
||||
$rechargeUser['controller_username'] = $zdl['username'];
|
||||
$rechargeUser['controller_nickname'] = $zdl['nickname'];
|
||||
$rechargeUser['controller_type'] = '总后台操作允许玩家提现,提现金额加到所属总代余额上';
|
||||
$rechargeUser['controller_old_money'] = $zdl['money'];
|
||||
$rechargeUser['controller_new_money'] = $zdl['money'] + $receivables_record['recharge_money'];
|
||||
$rechargeUser['user_id'] = $user['id'];
|
||||
$rechargeUser['user_type'] = $user['agent'];
|
||||
$rechargeUser['user_agent_level'] = 0;
|
||||
$rechargeUser['username_for'] = $user['username'];
|
||||
$rechargeUser['nickname_for'] = $user['nickname'];
|
||||
$rechargeUser['user_parent_id'] = $user['agent_parent_id'];
|
||||
$rechargeUser['admin_id'] = $user_info['id'];
|
||||
$rechargeUser['admin_user_name'] = $user_info['admin'];
|
||||
$rechargeUser['create_time'] = time();
|
||||
$rechargeUser['old_money'] = $user['money'] + $receivables_record['recharge_money'];
|
||||
$rechargeUser['new_money'] = $user['money'];
|
||||
$rechargeUser['controller_system'] = 3;
|
||||
$rechargeUser['remake'] = '总后台操作允许玩家提现,提现金额加到所属总代余额上';
|
||||
Db::name('recharge')->insert($rechargeUser);
|
||||
$zdlMoney = $zdl['money'] + $receivables_record['recharge_money'];
|
||||
Db::name('user')->where(array('id' => $zdlId))->limit(1)->update(array('money' => $zdlMoney));
|
||||
$result = Db::name('receivables_record')->where('id',$id)->update(array('status' => 1,'controller_admin'=>$user_info['admin']));
|
||||
if($result){
|
||||
insertAdminLog('提现充值',"提现充值 | 订单ID: ".$id);
|
||||
die(json_encode(['code'=>1,'msg'=>'提现成功!']));
|
||||
}else{
|
||||
die(json_encode(['code'=>1,'msg'=>'提现失败!']));
|
||||
}
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'页面错误']));
|
||||
}
|
||||
}
|
||||
public function do_add_remarks(){
|
||||
if(Request::instance()->post()){
|
||||
// 接收数据
|
||||
$id = Request::instance()->post('record_id');
|
||||
$remarks = Request::instance()->post('remarks');
|
||||
// 数据验证
|
||||
if(!$id){
|
||||
die(json_encode(['code'=>0,'msg'=>'提现记录不存在']));
|
||||
}
|
||||
if(!$remarks){
|
||||
die(json_encode(['code'=>0,'msg'=>'原因不能为空']));
|
||||
}
|
||||
$record_info = Db::name('receivables_record')->where('id',$id)->find();
|
||||
$player_info = Db::name('user')->where('id',$record_info['user_id'])->find();
|
||||
$user_info = Session::get('user_info');
|
||||
$result = Db::name('receivables_record')->where('id',$id)->update(array('status' => 2,'controller_admin'=>$user_info['admin'],'remarks'=>$remarks));
|
||||
if($result){
|
||||
$new_money = $player_info['money'] + $record_info['recharge_money'];
|
||||
Db::name('user')->where('id',$record_info['user_id'])->update(array('money' => $new_money));
|
||||
insertAdminLog('拒绝提现',"拒绝提现 | 订单ID: ".$id);
|
||||
die(json_encode(['code'=>1,'msg'=>'拒绝成功!']));
|
||||
}else{
|
||||
die(json_encode(['code'=>1,'msg'=>'拒绝失败!']));
|
||||
}
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'操作错误!']));
|
||||
}
|
||||
}
|
||||
public function do_add_remarks_recharge(){
|
||||
if(Request::instance()->post()){
|
||||
// 接收数据
|
||||
$id = Request::instance()->post('record_id');
|
||||
$remarks = Request::instance()->post('remarks');
|
||||
// 数据验证
|
||||
if(!$id){
|
||||
die(json_encode(['code'=>0,'msg'=>'充值记录不存在']));
|
||||
}
|
||||
if(!$remarks){
|
||||
die(json_encode(['code'=>0,'msg'=>'原因不能为空']));
|
||||
}
|
||||
$user_info = Session::get('user_info');
|
||||
$result = Db::name('receivables_record')->where('id',$id)->update(array('status' => 2,'controller_admin'=>$user_info['admin'],'remarks'=>$remarks));
|
||||
if($result){
|
||||
insertAdminLog('拒绝充值',"拒绝充值 | 订单ID: ".$id);
|
||||
die(json_encode(['code'=>1,'msg'=>'拒绝成功!']));
|
||||
}else{
|
||||
die(json_encode(['code'=>1,'msg'=>'拒绝失败!']));
|
||||
}
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'操作错误!']));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置
|
||||
*/
|
||||
public function setting()
|
||||
{
|
||||
$system = Db::name('system')->find();
|
||||
$this->assign('system',$system);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function saveSetting()
|
||||
{
|
||||
$post = Request::instance()->post();
|
||||
$data = [
|
||||
'recharge_money' => $post['recharge_money'],
|
||||
'withdraw_money' => $post['withdraw_money'],
|
||||
'withdraw_fee' => $post['withdraw_fee']
|
||||
];
|
||||
$system = Db::name('system')->find();
|
||||
if($system){
|
||||
$res = Db::name('system')->where('id',$system['id'])->update($data);
|
||||
}else{
|
||||
$res = Db::name('system')->insert($data);
|
||||
}
|
||||
|
||||
if($res){
|
||||
insertAdminLog('充值提现配置',"修改充值提现配置 ");
|
||||
die(json_encode(['code'=>1,'msg'=>'操作成功!']));
|
||||
}else{
|
||||
die(json_encode(['code'=>1,'msg'=>'操作失败!']));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,445 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use pay\Usdt;
|
||||
use think\Db;
|
||||
use think\Request;
|
||||
use think\Session;
|
||||
|
||||
class Report extends Common{
|
||||
// 收益报表
|
||||
public function profit(){
|
||||
// 接收分页的条件
|
||||
$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');
|
||||
$export = Request::instance()->get('export');
|
||||
$agent_id = Request::instance()->get('agent_id');
|
||||
|
||||
// 代理查询条件
|
||||
$where = array();
|
||||
// $where['agent_parent_id'] = 0;
|
||||
$where['agent'] = 1;
|
||||
if($username){
|
||||
$where['username'] = $username;
|
||||
unset($where['agent_parent_id']);
|
||||
}
|
||||
if($agent_id > 0){
|
||||
$where['agent_parent_id'] = $agent_id;
|
||||
}
|
||||
$agent_list = Db::name('user')->where($where)->select();
|
||||
|
||||
// 时间条件
|
||||
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);
|
||||
}
|
||||
$this->assign('get',$get);
|
||||
|
||||
// 数据查询条件
|
||||
$timeWhere = array();
|
||||
$timeWhere['create_time'] = array('between',[$startTime,$endTime]);
|
||||
$dataAgent = array();
|
||||
foreach($agent_list as $k => $v){
|
||||
// 查询是否有下级代理
|
||||
$v['child_agent'] = Db::name('user')->where('agent_parent_id',$v['id'])->count();
|
||||
// 自己的洗码收益
|
||||
$v['self_income_xima'] = Db::name('xima')->where('user_id',$v['id'])->where($timeWhere)->sum('maliang');
|
||||
$v['self_income_xima'] = $v['self_income_xima'] * (1 - $v['agent_cs']/100);
|
||||
// 自己的占成收益
|
||||
$v['self_income_cs'] = Db::name('cs')->where('user_id',$v['id'])->where($timeWhere)->sum('share_amount');
|
||||
// 总收益(自己的洗码 + 自己的占成)
|
||||
$v['total_income'] = $v['self_income_xima'] + $v['self_income_cs'];
|
||||
// 有数据才显示
|
||||
if($v['total_income'] != 0){
|
||||
$dataAgent[] = $v;
|
||||
}
|
||||
}
|
||||
$agent_list = $dataAgent;
|
||||
|
||||
//导出excel列表
|
||||
if($export == 1){
|
||||
if($agent_list){
|
||||
//重新组合
|
||||
$excelData = array();
|
||||
foreach($agent_list AS $k => $v){
|
||||
$excelData[$k][0] = $v['username'];
|
||||
$excelData[$k][1] = $v['agent_cs'];
|
||||
$excelData[$k][2] = $v['self_income_cs'];
|
||||
$excelData[$k][3] = $v['self_income_xima'];
|
||||
$excelData[$k][4] = $v['agent_ximalv'];
|
||||
$excelData[$k][5] = $v['total_income'];
|
||||
}
|
||||
$title = array('用户名','占成','占成收益','洗码率','洗码收益','总收益金额');
|
||||
if($startDate && $endDate){
|
||||
$this->exportExcelCore($excelData, '收益日报表-'.$startDate.'--'.$endDate, $title);
|
||||
}else{
|
||||
$this->exportExcelCore($excelData, '收益日报表', $title);
|
||||
}
|
||||
exit('已导出支持列表,请不要重复刷新该页面!');
|
||||
}else{
|
||||
exit('没有可以导出的列表!');
|
||||
}
|
||||
}
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('agent_list',$agent_list);
|
||||
return $this->fetch();
|
||||
}
|
||||
// 收益报表打印
|
||||
public function profit_print(){
|
||||
// 接收分页的条件
|
||||
$get = Request::instance()->get();
|
||||
$startDate = Request::instance()->get('startDate');
|
||||
$endDate = Request::instance()->get('endDate');
|
||||
$username = Request::instance()->get('username');
|
||||
$agent_id = Request::instance()->get('agent_id');
|
||||
|
||||
// 代理查询条件
|
||||
$where = array();
|
||||
$where['agent_parent_id'] = 0;
|
||||
$where['agent'] = 1;
|
||||
if($username){
|
||||
$where['username'] = $username;
|
||||
unset($where['agent_parent_id']);
|
||||
}
|
||||
if($agent_id > 0){
|
||||
$where['agent_parent_id'] = $agent_id;
|
||||
}
|
||||
$agent_list = Db::name('user')->where($where)->select();
|
||||
|
||||
// 统计数据的时间条件
|
||||
if(!$startDate){
|
||||
// 默认日期为当天
|
||||
$startDate = date('Y-m-d H:i:s',strtotime(date('Y-m-d')));
|
||||
$startTime = strtotime(date('Y-m-d'));
|
||||
}else{
|
||||
$startTime = strtotime($startDate);
|
||||
}
|
||||
if(!$endDate){
|
||||
// 默认日期为当天
|
||||
$endDate = date('Y-m-d H:i:s',time());
|
||||
$endTime = time();
|
||||
}else{
|
||||
$endTime = strtotime($endDate);
|
||||
}
|
||||
|
||||
// 查询数据条件
|
||||
$timeWhere = array();
|
||||
$timeWhere['create_time'] = array('between',[$startTime,$endTime]);
|
||||
$dataAgent = array();
|
||||
foreach($agent_list as $k => $v){
|
||||
// 自己的洗码收益
|
||||
$v['self_income_xima'] = Db::name('xima')->where('user_id',$v['id'])->where($timeWhere)->sum('maliang');
|
||||
$v['self_income_xima'] = $v['self_income_xima'] * (1 - $v['agent_cs']/100);
|
||||
// 自己的占成收益
|
||||
$v['self_income_cs'] = Db::name('cs')->where('user_id',$v['id'])->where($timeWhere)->sum('share_amount');
|
||||
// 总收益
|
||||
$v['total_income'] = $v['self_income_xima'] + $v['self_income_cs'];
|
||||
// 有数据才显示
|
||||
if($v['total_income'] != 0){
|
||||
$dataAgent[] = $v;
|
||||
}
|
||||
}
|
||||
$agent_list = $dataAgent;
|
||||
// 渲染参数和模板
|
||||
$this->assign('agent_list',$agent_list);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
|
||||
// 充值查询
|
||||
public function user_recharge(){
|
||||
|
||||
// 用于分页和搜索查询的数据
|
||||
$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');
|
||||
$export = Request::instance()->get('export');
|
||||
|
||||
// 转换日期时间
|
||||
if($startDate){
|
||||
$startTime = strtotime($startDate);
|
||||
}else{
|
||||
$startTime = 0;
|
||||
}
|
||||
if($endDate){
|
||||
$endTime = strtotime($endDate);
|
||||
}else{
|
||||
$endTime = time();
|
||||
}
|
||||
|
||||
// 拼装搜索条件
|
||||
$where = array();
|
||||
$whereStr = '';
|
||||
$where['create_time'] = array('between',[$startTime,$endTime]);
|
||||
if($username){
|
||||
$user = Db::connect('DB2')->name('user')->where(['username'=>$username,'is_delete'=>0])->find();
|
||||
if($user){
|
||||
// $where['user_id'] = $user['id'];
|
||||
$whereStr = "find_in_set({$user['id']},u.agent_parent_id_path)";
|
||||
}else{
|
||||
$where['user_id'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$list = Db::connect('DB2')->name('user_recharge')
|
||||
->alias('r')
|
||||
->field('r.*,u.username,u.nickname')
|
||||
->join('cg_user u','r.user_id=u.id')
|
||||
->where($where)
|
||||
->where($whereStr)
|
||||
->order('r.id desc')
|
||||
->paginate(20,false,array('query'=>$get));
|
||||
foreach($list as $k => $v){
|
||||
// 信息组装
|
||||
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
|
||||
|
||||
// 数据格式转换
|
||||
$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;
|
||||
}
|
||||
|
||||
// 汇总金额
|
||||
$total = Db::connect('DB2')
|
||||
->name('user_recharge')
|
||||
->alias('r')
|
||||
->field('sum(r.amount) as amount, sum(r.money) as money')
|
||||
->join('cg_user u','r.user_id=u.id')
|
||||
->where($where)->find();
|
||||
|
||||
//导出excel列表
|
||||
if($export == 1){
|
||||
if($list){
|
||||
//重新组合
|
||||
$excelData = array();
|
||||
foreach($list AS $k => $v){
|
||||
$excelData[$k][] = $v['nickname'];
|
||||
$excelData[$k][] = $v['username'];
|
||||
$excelData[$k][] = $v['amount'];
|
||||
$excelData[$k][] = $v['money'];
|
||||
$excelData[$k][] = $v['old_money'];
|
||||
$excelData[$k][] = $v['new_money'];
|
||||
$excelData[$k][] = $v['out_trade_no'];
|
||||
$excelData[$k][] = $v['from_addr'];
|
||||
$excelData[$k][] = $v['to_addr'];
|
||||
}
|
||||
$title = array('用户名','帐号','充值U币','充值金额','充值前余额','充值后余额','外部交易号','转账地址','入账地址');
|
||||
if($startDate && $endDate){
|
||||
$this->exportExcelCore($excelData, '充值报表-'.$startDate.'--'.$endDate, $title);
|
||||
}else{
|
||||
$this->exportExcelCore($excelData, '充值报表', $title);
|
||||
}
|
||||
exit('已导出支持列表,请不要重复刷新该页面!');
|
||||
}else{
|
||||
exit('没有可以导出的列表!');
|
||||
}
|
||||
}
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('list',$list);
|
||||
$this->assign('total',$total);
|
||||
return $this->fetch();
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 提现查询
|
||||
public function user_withdraw(){
|
||||
// 用于分页和搜索查询的数据
|
||||
$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');
|
||||
$export = Request::instance()->get('export');
|
||||
|
||||
// 转换日期时间
|
||||
if($startDate){
|
||||
$startTime = strtotime($startDate);
|
||||
}else{
|
||||
$startTime = 0;
|
||||
}
|
||||
if($endDate){
|
||||
$endTime = strtotime($endDate);
|
||||
}else{
|
||||
$endTime = time();
|
||||
}
|
||||
|
||||
// 拼装搜索条件
|
||||
$where = array();
|
||||
$whereStr = '';
|
||||
$where['create_time'] = array('between',[$startTime,$endTime]);
|
||||
if($username){
|
||||
$user = Db::connect('DB2')->name('user')->where(['username'=>$username,'is_delete'=>0])->find();
|
||||
if($user){
|
||||
// $where['user_id'] = $user['id'];
|
||||
$whereStr = "find_in_set({$user['id']},u.agent_parent_id_path)";
|
||||
}else{
|
||||
$where['user_id'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$list = Db::connect('DB2')->name('user_withdraw')
|
||||
->alias('r')
|
||||
->field('r.*,u.username,u.nickname')
|
||||
->join('cg_user u','r.user_id=u.id')
|
||||
->where($where)
|
||||
->where($whereStr)
|
||||
->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;
|
||||
}
|
||||
|
||||
// 汇总金额
|
||||
$total = Db::connect('DB2')
|
||||
->name('user_withdraw')
|
||||
->alias('r')
|
||||
->field('sum(r.amount) as amount, sum(r.service_fee) as service_fee, sum(r.money) as money, sum(r.service_fee_money) as service_fee_money')
|
||||
->join('cg_user u','r.user_id=u.id')
|
||||
->where($where)->find();
|
||||
|
||||
//导出excel列表
|
||||
if($export == 1){
|
||||
if($list){
|
||||
//重新组合
|
||||
$excelData = array();
|
||||
foreach($list AS $k => $v){
|
||||
$excelData[$k][] = $v['create_time'];
|
||||
$excelData[$k][] = $v['nickname'];
|
||||
$excelData[$k][] = $v['username'];
|
||||
$excelData[$k][] = $v['amount'];
|
||||
$excelData[$k][] = $v['service_fee'];
|
||||
$excelData[$k][] = $v['money'];
|
||||
$excelData[$k][] = $v['service_fee_money'];
|
||||
$excelData[$k][] = $v['old_money'];
|
||||
$excelData[$k][] = $v['new_money'];
|
||||
$excelData[$k][] = $v['status_msg'];
|
||||
$excelData[$k][] = $v['operator_nickname']."(".$v['operator_username'].")";
|
||||
$excelData[$k][] = $v['operator_source_msg'];
|
||||
}
|
||||
$title = array('时间','用户名','帐号','提现U币','手续费(U币)','提现金额','手续费金额','提现前余额','提现后余额','审核状态','操作人[账号]','操作类型');
|
||||
if($startDate && $endDate){
|
||||
$this->exportExcelCore($excelData, '提现报表-'.$startDate.'--'.$endDate, $title);
|
||||
}else{
|
||||
$this->exportExcelCore($excelData, '提现报表', $title);
|
||||
}
|
||||
exit('已导出支持列表,请不要重复刷新该页面!');
|
||||
}else{
|
||||
exit('没有可以导出的列表!');
|
||||
}
|
||||
}
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('list',$list);
|
||||
$this->assign('total',$total);
|
||||
return $this->fetch();
|
||||
}
|
||||
// 处理提现
|
||||
public function doUserWithdraw()
|
||||
{
|
||||
if(Request::instance()->isPost()){
|
||||
// 总代类型判断 1现金线
|
||||
$user_info = Session::get('user_info');
|
||||
$user_info = Db::connect('DB2')->name('admin')->where('id',$user_info['id'])->find();
|
||||
|
||||
$id = Request::instance()->post('id');
|
||||
$withdraw = Db::name('user_withdraw')->where('id',$id)->find();
|
||||
if(empty($withdraw) || $withdraw['status'] != "WAIT"){
|
||||
die(json_encode(['code'=>0,'msg'=>'非待审核状态无法操作!']));
|
||||
}
|
||||
|
||||
// 审核通过
|
||||
$Usdt = new Usdt();
|
||||
$res = $Usdt->applyUserWithdraw($withdraw['order_no'],$withdraw['to_address'],$withdraw['amount']);
|
||||
if($res['code'] == 0){
|
||||
Db::name('user_withdraw')->where('id',$id)->update([
|
||||
'status' => 'AGREE',
|
||||
'type' => $res['processor']['asset'],
|
||||
'from_address' => $res['processor']['from_addr'],
|
||||
'audit_time' => time(),
|
||||
'operator_source' => 2,
|
||||
'operator_id' => $user_info['id'],
|
||||
'operator_username' => $user_info['admin'],
|
||||
]);
|
||||
die(json_encode(['code'=>1,'msg'=>'审核通过!']));
|
||||
}else{
|
||||
Db::startTrans();
|
||||
|
||||
// 退返余额
|
||||
$user = Db::name('user')->where('id',$withdraw['user_id'])->lock(true)->find();
|
||||
$money = $user['money'] + $withdraw['money'] + $withdraw['service_fee_money'];
|
||||
Db::name('user')->where('id',$withdraw['user_id'])->update(['money' => $money]);
|
||||
|
||||
// 更新记录
|
||||
Db::name('user_withdraw')->where('id',$id)->update([
|
||||
'status' => 'FAIL',
|
||||
'err_msg' => $res['debug'],
|
||||
'audit_time' => time(),
|
||||
'operator_source' => 2,
|
||||
'operator_id' => $user_info['id'],
|
||||
'operator_username' => $user_info['admin']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
die(json_encode(['code'=>0,'msg'=>'提现失败!']));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,847 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\Db;
|
||||
use think\Request;
|
||||
use think\Session;
|
||||
|
||||
class Table extends Common{
|
||||
/**
|
||||
* 百家乐桌子账目
|
||||
*/
|
||||
public function baccarat()
|
||||
{
|
||||
// 接收分页的条件
|
||||
$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');
|
||||
$table_id = Request::instance()->get('table_id');
|
||||
$export = Request::instance()->get('export');
|
||||
|
||||
// 百家乐所有桌子信息
|
||||
$table_list = Db::name('table')->where('game_id',1)->select();
|
||||
if($table_id > 0){
|
||||
$table = Db::name('table')->where('game_id',1)->where('id',$table_id)->paginate(10,false,array('query'=>$get));
|
||||
}else{
|
||||
if($export == 1){
|
||||
$table = Db::name('table')->where('game_id',1)->select();
|
||||
}else{
|
||||
$table = Db::name('table')->where('game_id',1)->paginate(10,false,array('query'=>$get));
|
||||
}
|
||||
}
|
||||
|
||||
// 定义百家乐汇总参数
|
||||
$total_baccarat = array();
|
||||
$total_baccarat['total_sum'] = 0;
|
||||
$total_baccarat['total_win_sum'] = 0;
|
||||
$total_baccarat['ximaliang'] = 0;
|
||||
$total_baccarat['total_maliang'] = 0;
|
||||
$total_baccarat['income'] = 0;
|
||||
|
||||
// 时间条件
|
||||
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);
|
||||
}
|
||||
$this->assign('get',$get);
|
||||
|
||||
// 拼装数据
|
||||
foreach($table AS $k => $v){
|
||||
// 注单查询条件
|
||||
$betWhere = array();
|
||||
$betWhere['create_time'] = array('between',[$startTime,$endTime]);
|
||||
$betWhere['table_id'] = $v['id'];
|
||||
$v['status'] = 1;
|
||||
// 洗码查询条件
|
||||
$ximaWhere = array();
|
||||
$ximaWhere['table_id'] = $v['id'];
|
||||
$ximaWhere['status'] = 1;
|
||||
$ximaWhere['type'] = 1;
|
||||
$ximaWhere['ximaliang'] = array('gt',0);
|
||||
$ximaWhere['create_time'] = array('between',[$startTime,$endTime]);
|
||||
// 结果统计查询条件
|
||||
$betCountWhere = array();
|
||||
$betCountWhere['table_id'] = $v['id'];
|
||||
$betCountWhere['start_time'] = array('between',[$startTime,$endTime]);
|
||||
|
||||
//庄下注总额
|
||||
$v['bankerSum'] = Db::name('bet')->where($betWhere)->sum('banker_amount');
|
||||
//闲下注总额
|
||||
$v['playerSum'] = Db::name('bet')->where($betWhere)->sum('player_amount');
|
||||
//和下注总额
|
||||
$v['tieSum'] = Db::name('bet')->where($betWhere)->sum('tie_amount');
|
||||
//庄对下注总额
|
||||
$v['bankerPairSum'] = Db::name('bet')->where($betWhere)->sum('banker_pair_amount');
|
||||
//闲对下注总额
|
||||
$v['playerPairSum'] = Db::name('bet')->where($betWhere)->sum('player_pair_amount');
|
||||
//庄次数
|
||||
$betCountWhere['result'] = 1;
|
||||
$v['bankerCount'] = Db::name('number_tab')->where($betCountWhere)->count();
|
||||
//闲次数
|
||||
$betCountWhere['result'] = 2;
|
||||
$v['playerCount'] = Db::name('number_tab')->where($betCountWhere)->count();
|
||||
//和次数
|
||||
$betCountWhere['result'] = 3;
|
||||
$v['tieCount'] = Db::name('number_tab')->where($betCountWhere)->count();
|
||||
//庄对次数
|
||||
unset($betCountWhere['result']);
|
||||
$betCountWhere['pair'] = 1;
|
||||
$v['bankerPairCount'] = Db::name('number_tab')->where($betCountWhere)->count();
|
||||
//闲对次数
|
||||
$betCountWhere['pair'] = 2;
|
||||
$v['playerPairCount'] = Db::name('number_tab')->where($betCountWhere)->count();
|
||||
//庄闲对次数
|
||||
$betCountWhere['pair'] = 3;
|
||||
$v['bankerPlayerPairCount'] = Db::name('number_tab')->where($betCountWhere)->count();
|
||||
//总下注金额
|
||||
$v['totalSum'] = $v['bankerSum'] + $v['playerSum'] + $v['tieSum'] + $v['bankerPairSum'] + $v['playerPairSum'];
|
||||
//总赢
|
||||
$v['totalWinSum'] = Db::name('bet')->where($betWhere)->sum('win_total');
|
||||
//洗码量
|
||||
$v['ximaliang'] = Db::name('xima')->where($ximaWhere)->sum('ximaliang');
|
||||
//码量
|
||||
$v['totalMaliang'] = Db::name('xima')->where($ximaWhere)->sum('maliang');
|
||||
//收益
|
||||
$v['income'] = to_number($v['totalWinSum']);
|
||||
|
||||
$table[$k] = $v;
|
||||
// 汇总参数
|
||||
$total_baccarat['total_sum'] += $v['totalSum'];
|
||||
$total_baccarat['total_win_sum'] += $v['totalWinSum'];
|
||||
$total_baccarat['ximaliang'] += $v['ximaliang'];
|
||||
$total_baccarat['total_maliang'] += $v['totalMaliang'];
|
||||
$total_baccarat['income'] += $v['income'];
|
||||
}
|
||||
|
||||
//导出excel列表
|
||||
if($export == 1){
|
||||
if($table){
|
||||
//重新组合
|
||||
$excelData = array();
|
||||
foreach($table AS $k => $v){
|
||||
$excelData[$k][0] = $v['table_name'];
|
||||
$excelData[$k][1] = $v['bankerSum'];
|
||||
$excelData[$k][2] = $v['playerSum'];
|
||||
$excelData[$k][3] = $v['tieSum'];
|
||||
$excelData[$k][4] = $v['bankerPairSum'];
|
||||
$excelData[$k][5] = $v['playerPairSum'];
|
||||
$excelData[$k][6] = $v['bankerCount'];
|
||||
$excelData[$k][7] = $v['playerCount'];
|
||||
$excelData[$k][8] = $v['tieCount'];
|
||||
$excelData[$k][9] = $v['bankerPairCount'];
|
||||
$excelData[$k][10] = $v['playerPairCount'];
|
||||
$excelData[$k][11] = $v['bankerPlayerPairCount'];
|
||||
$excelData[$k][12] = $v['totalSum'];
|
||||
$excelData[$k][13] = $v['totalWinSum'];
|
||||
$excelData[$k][14] = $v['ximaliang'];
|
||||
$excelData[$k][15] = $v['totalMaliang'];
|
||||
$excelData[$k][16] = $v['income'];
|
||||
}
|
||||
$title = array('桌号','庄(下注额)','闲(下注额)','和(下注额)','庄对(下注额)','闲对(下注额)','庄(次)','闲(次)','和(次)','庄对(次)','闲对(次)','庄闲对(次)','总押','会员赢','洗码量','码量','收益');
|
||||
if($startDate && $endDate){
|
||||
$this->exportExcelCore($excelData, '百家乐桌子账目-'.$startDate.'--'.$endDate, $title);
|
||||
}else{
|
||||
$this->exportExcelCore($excelData, '百家乐桌子账目', $title);
|
||||
}
|
||||
exit('已导出支持列表,请不要重复刷新该页面!');
|
||||
}else{
|
||||
exit('没有可以导出的列表!');
|
||||
}
|
||||
}
|
||||
|
||||
$this->assign('table',$table);
|
||||
$this->assign('table_list',$table_list);
|
||||
$this->assign('total_baccarat',$total_baccarat);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 龙虎斗桌子账目
|
||||
*/
|
||||
public function dt()
|
||||
{
|
||||
// 接收分页的条件
|
||||
$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');
|
||||
$table_id = Request::instance()->get('table_id');
|
||||
$export = Request::instance()->get('export');
|
||||
|
||||
// 百家乐所有桌子信息
|
||||
$table_list = Db::name('table')->where('game_id',2)->select();
|
||||
if($table_id > 0){
|
||||
$table = Db::name('table')->where('game_id',2)->where('id',$table_id)->paginate(10,false,array('query'=>$get));
|
||||
}else{
|
||||
if($export == 1){
|
||||
$table = Db::name('table')->where('game_id',2)->select();
|
||||
}else{
|
||||
$table = Db::name('table')->where('game_id',2)->paginate(10,false,array('query'=>$get));
|
||||
}
|
||||
}
|
||||
|
||||
// 定义百家乐汇总参数
|
||||
$total_dt = array();
|
||||
$total_dt['total_sum'] = 0;
|
||||
$total_dt['total_win_sum'] = 0;
|
||||
$total_dt['ximaliang'] = 0;
|
||||
$total_dt['total_maliang'] = 0;
|
||||
$total_dt['income'] = 0;
|
||||
|
||||
// 时间条件
|
||||
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);
|
||||
}
|
||||
$this->assign('get',$get);
|
||||
|
||||
// 拼装数据
|
||||
foreach($table AS $k => $v){
|
||||
// 注单查询条件
|
||||
$betWhere = array();
|
||||
$betWhere['create_time'] = array('between',[$startTime,$endTime]);
|
||||
$betWhere['table_id'] = $v['id'];
|
||||
$v['status'] = 1;
|
||||
// 洗码查询条件
|
||||
$ximaWhere = array();
|
||||
$ximaWhere['table_id'] = $v['id'];
|
||||
$ximaWhere['status'] = 1;
|
||||
$ximaWhere['type'] = 1;
|
||||
$ximaWhere['ximaliang'] = array('gt',0);
|
||||
$ximaWhere['create_time'] = array('between',[$startTime,$endTime]);
|
||||
// 结果统计查询条件
|
||||
$betCountWhere = array();
|
||||
$betCountWhere['table_id'] = $v['id'];
|
||||
$betCountWhere['start_time'] = array('between',[$startTime,$endTime]);
|
||||
|
||||
//龙下注总额
|
||||
$v['bankerSum'] = Db::name('bet')->where($betWhere)->sum('banker_amount');
|
||||
//虎下注总额
|
||||
$v['playerSum'] = Db::name('bet')->where($betWhere)->sum('player_amount');
|
||||
//和下注总额
|
||||
$v['tieSum'] = Db::name('bet')->where($betWhere)->sum('tie_amount');
|
||||
//龙次数
|
||||
$betCountWhere['result'] = 1;
|
||||
$v['bankerCount'] = Db::name('number_tab')->where($betCountWhere)->count();
|
||||
//虎次数
|
||||
$betCountWhere['result'] = 2;
|
||||
$v['playerCount'] = Db::name('number_tab')->where($betCountWhere)->count();
|
||||
//和次数
|
||||
$betCountWhere['result'] = 3;
|
||||
$v['tieCount'] = Db::name('number_tab')->where($betCountWhere)->count();
|
||||
//总下注金额
|
||||
$v['totalSum'] = $v['bankerSum'] + $v['playerSum'] + $v['tieSum'];
|
||||
//总赢
|
||||
$v['totalWinSum'] = Db::name('bet')->where($betWhere)->sum('win_total');
|
||||
//收益
|
||||
$v['income'] = to_number($v['totalWinSum']);
|
||||
|
||||
$table[$k] = $v;
|
||||
// 汇总参数
|
||||
$total_dt['total_sum'] += $v['totalSum'];
|
||||
$total_dt['total_win_sum'] += $v['totalWinSum'];
|
||||
$total_dt['income'] += $v['income'];
|
||||
}
|
||||
|
||||
//导出excel列表
|
||||
if($export == 1){
|
||||
if($table){
|
||||
//重新组合
|
||||
$excelData = array();
|
||||
foreach($table AS $k => $v){
|
||||
$excelData[$k][0] = $v['table_name'];
|
||||
$excelData[$k][1] = $v['bankerSum'];
|
||||
$excelData[$k][2] = $v['playerSum'];
|
||||
$excelData[$k][3] = $v['tieSum'];
|
||||
$excelData[$k][4] = $v['bankerCount'];
|
||||
$excelData[$k][5] = $v['playerCount'];
|
||||
$excelData[$k][6] = $v['tieCount'];
|
||||
$excelData[$k][7] = $v['totalSum'];
|
||||
$excelData[$k][8] = $v['totalWinSum'];
|
||||
$excelData[$k][9] = $v['income'];
|
||||
}
|
||||
$title = array('桌号','龙(下注额)','虎(下注额)','和(下注额)','龙(次)','虎(次)','和(次)','总押','会员赢','收益');
|
||||
if($startDate && $endDate){
|
||||
$this->exportExcelCore($excelData, '龙虎斗桌子账目-'.$startDate.'--'.$endDate, $title);
|
||||
}else{
|
||||
$this->exportExcelCore($excelData, '龙虎斗桌子账目', $title);
|
||||
}
|
||||
exit('已导出支持列表,请不要重复刷新该页面!');
|
||||
}else{
|
||||
exit('没有可以导出的列表!');
|
||||
}
|
||||
}
|
||||
|
||||
$this->assign('table',$table);
|
||||
$this->assign('table_list',$table_list);
|
||||
$this->assign('total_dt',$total_dt);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 牛牛桌子账目
|
||||
*/
|
||||
public function nn()
|
||||
{
|
||||
// 接收分页的条件
|
||||
$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');
|
||||
$table_id = Request::instance()->get('table_id');
|
||||
$export = Request::instance()->get('export');
|
||||
|
||||
// 牛牛所有桌子信息
|
||||
$table_list = Db::name('table')->where('game_id',4)->select();
|
||||
if($table_id > 0){
|
||||
$table = Db::name('table')->where('game_id',4)->where('id',$table_id)->paginate(10,false,array('query'=>$get));
|
||||
}else{
|
||||
if($export == 1){
|
||||
$table = Db::name('table')->where('game_id',4)->select();
|
||||
}else{
|
||||
$table = Db::name('table')->where('game_id',4)->paginate(10,false,array('query'=>$get));
|
||||
}
|
||||
}
|
||||
|
||||
// 定义牛牛汇总参数
|
||||
$total_nn = array();
|
||||
$total_nn['total_sum'] = 0;
|
||||
$total_nn['total_win_sum'] = 0;
|
||||
$total_nn['ximaliang'] = 0;
|
||||
$total_nn['total_maliang'] = 0;
|
||||
$total_nn['income'] = 0;
|
||||
|
||||
// 时间条件
|
||||
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);
|
||||
}
|
||||
$this->assign('get',$get);
|
||||
|
||||
// 拼装数据
|
||||
foreach($table AS $k => $v){
|
||||
// 注单查询条件
|
||||
$betWhere = array();
|
||||
$betWhere['create_time'] = array('between',[$startTime,$endTime]);
|
||||
$betWhere['table_id'] = $v['id'];
|
||||
$v['status'] = 1;
|
||||
// 洗码查询条件
|
||||
$ximaWhere = array();
|
||||
$ximaWhere['table_id'] = $v['id'];
|
||||
$ximaWhere['status'] = 1;
|
||||
$ximaWhere['type'] = 1;
|
||||
$ximaWhere['ximaliang'] = array('gt',0);
|
||||
$ximaWhere['create_time'] = array('between',[$startTime,$endTime]);
|
||||
// 结果统计查询条件
|
||||
$betCountWhere = array();
|
||||
$betCountWhere['table_id'] = $v['id'];
|
||||
$betCountWhere['start_time'] = array('between',[$startTime,$endTime]);
|
||||
|
||||
$v['amount_player_1_Sum'] = Db::name('bet')->where($betWhere)->sum('amount_player_1');
|
||||
$v['amount_player_1_times_Sum'] = Db::name('bet')->where($betWhere)->sum('amount_player_1_times');
|
||||
$v['amount_player_1_banker_Sum'] = Db::name('bet')->where($betWhere)->sum('amount_player_1_banker');
|
||||
$v['amount_player_1_banker_times_Sum'] = Db::name('bet')->where($betWhere)->sum('amount_player_1_banker_times');
|
||||
$v['amount_player_2_Sum'] = Db::name('bet')->where($betWhere)->sum('amount_player_2');
|
||||
$v['amount_player_2_times_Sum'] = Db::name('bet')->where($betWhere)->sum('amount_player_2_times');
|
||||
$v['amount_player_2_banker_Sum'] = Db::name('bet')->where($betWhere)->sum('amount_player_2_banker');
|
||||
$v['amount_player_2_banker_times_Sum'] = Db::name('bet')->where($betWhere)->sum('amount_player_2_banker_times');
|
||||
$v['amount_player_3_Sum'] = Db::name('bet')->where($betWhere)->sum('amount_player_3');
|
||||
$v['amount_player_3_times_Sum'] = Db::name('bet')->where($betWhere)->sum('amount_player_3_times');
|
||||
$v['amount_player_3_banker_Sum'] = Db::name('bet')->where($betWhere)->sum('amount_player_3_banker');
|
||||
$v['amount_player_3_banker_times_Sum'] = Db::name('bet')->where($betWhere)->sum('amount_player_3_banker_times');
|
||||
//闲一次数
|
||||
$win_player_1['win_player_1'] = 1;
|
||||
$v['win_player_1'] = Db::name('number_tab')->where($win_player_1)->count();
|
||||
//闲二次数
|
||||
$win_player_2['win_player_2'] = 1;
|
||||
$v['win_player_2'] = Db::name('number_tab')->where($win_player_2)->count();
|
||||
//闲三次数
|
||||
$win_player_3['win_player_3'] = 1;
|
||||
$v['win_player_3'] = Db::name('number_tab')->where($win_player_3)->count();
|
||||
//庄次数
|
||||
$win_banker['win_player_1'] = 0;
|
||||
$win_banker['win_player_2'] = 0;
|
||||
$win_banker['win_player_2'] = 0;
|
||||
$v['win_banker'] = Db::name('number_tab')->where($win_banker)->count();
|
||||
//总下注金额
|
||||
$v['totalSum'] = $v['amount_player_1_Sum'] + $v['amount_player_1_times_Sum']+ $v['amount_player_1_banker_Sum']+ $v['amount_player_1_banker_times_Sum']+$v['amount_player_2_Sum'] + $v['amount_player_2_times_Sum']+ $v['amount_player_2_banker_Sum']+ $v['amount_player_2_banker_times_Sum']+$v['amount_player_3_Sum'] + $v['amount_player_3_times_Sum']+ $v['amount_player_3_banker_Sum']+ $v['amount_player_3_banker_times_Sum'];
|
||||
//总赢
|
||||
$v['totalWinSum'] = Db::name('bet')->where($betWhere)->sum('win_total');
|
||||
//收益
|
||||
$v['income'] = to_number($v['totalWinSum']);
|
||||
|
||||
$table[$k] = $v;
|
||||
// 汇总参数
|
||||
$total_nn['total_sum'] += $v['totalSum'];
|
||||
$total_nn['total_win_sum'] += $v['totalWinSum'];
|
||||
$total_nn['income'] += $v['income'];
|
||||
}
|
||||
//导出excel列表
|
||||
if($export == 1){
|
||||
if($table){
|
||||
//重新组合
|
||||
$excelData = array();
|
||||
foreach($table AS $k => $v){
|
||||
$excelData[$k][0] = $v['table_name'];
|
||||
$excelData[$k][1] = $v['amount_player_1_Sum'];
|
||||
$excelData[$k][2] = $v['amount_player_1_times_Sum'];
|
||||
$excelData[$k][3] = $v['amount_player_1_banker_Sum'];
|
||||
$excelData[$k][4] = $v['amount_player_1_banker_times_Sum'];
|
||||
$excelData[$k][5] = $v['amount_player_2_Sum'];
|
||||
$excelData[$k][6] = $v['amount_player_2_times_Sum'];
|
||||
$excelData[$k][7] = $v['amount_player_2_banker_Sum'];
|
||||
$excelData[$k][8] = $v['amount_player_2_banker_times_Sum'];
|
||||
$excelData[$k][9] = $v['amount_player_3_Sum'];
|
||||
$excelData[$k][10] = $v['amount_player_3_times_Sum'];
|
||||
$excelData[$k][11] = $v['amount_player_3_banker_Sum'];
|
||||
$excelData[$k][12] = $v['amount_player_3_banker_times_Sum'];
|
||||
$excelData[$k][13] = $v['win_banker'];
|
||||
$excelData[$k][14] = $v['win_player_1'];
|
||||
$excelData[$k][15] = $v['win_player_2'];
|
||||
$excelData[$k][16] = $v['win_player_3'];
|
||||
$excelData[$k][17] = $v['totalSum'];
|
||||
$excelData[$k][18] = $v['totalWinSum'];
|
||||
$excelData[$k][19] = $v['income'];
|
||||
}
|
||||
$title = array('桌号','闲一','闲一翻倍','闲一-庄','闲一-庄翻倍','闲二','闲二翻倍','闲二-庄','闲二-庄翻倍','闲三','闲三翻倍','闲三-庄','闲三-庄翻倍','庄(次)','闲一(次)','闲二(次)','闲三(次)','总押','会员赢','收益');
|
||||
if($startDate && $endDate){
|
||||
$this->exportExcelCore($excelData, '斗牛桌子账目-'.$startDate.'--'.$endDate, $title);
|
||||
}else{
|
||||
$this->exportExcelCore($excelData, '斗牛桌子账目', $title);
|
||||
}
|
||||
exit('已导出支持列表,请不要重复刷新该页面!');
|
||||
}else{
|
||||
exit('没有可以导出的列表!');
|
||||
}
|
||||
}
|
||||
$this->assign('table',$table);
|
||||
$this->assign('table_list',$table_list);
|
||||
$this->assign('total_nn',$total_nn);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function baccarat_print(){
|
||||
// 接收参数
|
||||
$startDate = Request::instance()->get('startDate');
|
||||
$endDate = Request::instance()->get('endDate');
|
||||
$table_id = Request::instance()->get('table_id');
|
||||
|
||||
// 查询桌子
|
||||
if($table_id > 0){
|
||||
$table = Db::name('table')->where('game_id',1)->where('id',$table_id)->select();
|
||||
}else{
|
||||
$table = Db::name('table')->where('game_id',1)->select();
|
||||
}
|
||||
|
||||
// 定义百家乐汇总参数
|
||||
$total_baccarat = array();
|
||||
$total_baccarat['total_sum'] = 0;
|
||||
$total_baccarat['total_win_sum'] = 0;
|
||||
$total_baccarat['ximaliang'] = 0;
|
||||
$total_baccarat['total_maliang'] = 0;
|
||||
$total_baccarat['income'] = 0;
|
||||
|
||||
// 时间条件
|
||||
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);
|
||||
}
|
||||
$this->assign('get',$get);
|
||||
|
||||
// 拼装数据
|
||||
foreach($table AS $k => $v){
|
||||
// 注单查询条件
|
||||
$betWhere = array();
|
||||
$betWhere['create_time'] = array('between',[$startTime,$endTime]);
|
||||
$betWhere['table_id'] = $v['id'];
|
||||
$v['status'] = 1;
|
||||
// 洗码查询条件
|
||||
$ximaWhere = array();
|
||||
$ximaWhere['table_id'] = $v['id'];
|
||||
$ximaWhere['status'] = 1;
|
||||
$ximaWhere['type'] = 1;
|
||||
$ximaWhere['ximaliang'] = array('gt',0);
|
||||
$ximaWhere['create_time'] = array('between',[$startTime,$endTime]);
|
||||
// 结果统计查询条件
|
||||
$betCountWhere = array();
|
||||
$betCountWhere['table_id'] = $v['id'];
|
||||
$betCountWhere['start_time'] = array('between',[$startTime,$endTime]);
|
||||
|
||||
//庄下注总额
|
||||
$v['bankerSum'] = Db::name('bet')->where($betWhere)->sum('banker_amount');
|
||||
//闲下注总额
|
||||
$v['playerSum'] = Db::name('bet')->where($betWhere)->sum('player_amount');
|
||||
//和下注总额
|
||||
$v['tieSum'] = Db::name('bet')->where($betWhere)->sum('tie_amount');
|
||||
//庄对下注总额
|
||||
$v['bankerPairSum'] = Db::name('bet')->where($betWhere)->sum('banker_pair_amount');
|
||||
//闲对下注总额
|
||||
$v['playerPairSum'] = Db::name('bet')->where($betWhere)->sum('player_pair_amount');
|
||||
//庄次数
|
||||
$betCountWhere['result'] = 1;
|
||||
$v['bankerCount'] = Db::name('number_tab')->where($betCountWhere)->count();
|
||||
//闲次数
|
||||
$betCountWhere['result'] = 2;
|
||||
$v['playerCount'] = Db::name('number_tab')->where($betCountWhere)->count();
|
||||
//和次数
|
||||
$betCountWhere['result'] = 3;
|
||||
$v['tieCount'] = Db::name('number_tab')->where($betCountWhere)->count();
|
||||
//庄对次数
|
||||
unset($betCountWhere['result']);
|
||||
$betCountWhere['pair'] = 1;
|
||||
$v['bankerPairCount'] = Db::name('number_tab')->where($betCountWhere)->count();
|
||||
//闲对次数
|
||||
$betCountWhere['pair'] = 2;
|
||||
$v['playerPairCount'] = Db::name('number_tab')->where($betCountWhere)->count();
|
||||
//庄闲对次数
|
||||
$betCountWhere['pair'] = 3;
|
||||
$v['bankerPlayerPairCount'] = Db::name('number_tab')->where($betCountWhere)->count();
|
||||
//总下注金额
|
||||
$v['totalSum'] = $v['bankerSum'] + $v['playerSum'] + $v['tieSum'] + $v['bankerPairSum'] + $v['playerPairSum'];
|
||||
//总赢
|
||||
$v['totalWinSum'] = Db::name('bet')->where($betWhere)->sum('win_total');
|
||||
//洗码量
|
||||
$v['ximaliang'] = Db::name('xima')->where($ximaWhere)->sum('ximaliang');
|
||||
//码量
|
||||
$v['totalMaliang'] = Db::name('xima')->where($ximaWhere)->sum('maliang');
|
||||
//收益
|
||||
$v['income'] = to_number($v['totalWinSum']);
|
||||
// 记账日期
|
||||
|
||||
$table[$k] = $v;
|
||||
// 汇总参数
|
||||
$total_baccarat['total_sum'] += $v['totalSum'];
|
||||
$total_baccarat['total_win_sum'] += $v['totalWinSum'];
|
||||
$total_baccarat['ximaliang'] += $v['ximaliang'];
|
||||
$total_baccarat['total_maliang'] += $v['totalMaliang'];
|
||||
$total_baccarat['income'] += $v['income'];
|
||||
}
|
||||
$this->assign('table',$table);
|
||||
$this->assign('total_baccarat',$total_baccarat);
|
||||
return $this->fetch();
|
||||
}
|
||||
public function dt_print(){
|
||||
// 接收参数
|
||||
$startDate = Request::instance()->get('startDate');
|
||||
$endDate = Request::instance()->get('endDate');
|
||||
$table_id = Request::instance()->get('table_id');
|
||||
|
||||
// 查询桌子
|
||||
if($table_id > 0){
|
||||
$table = Db::name('table')->where('game_id',2)->where('id',$table_id)->select();
|
||||
}else{
|
||||
$table = Db::name('table')->where('game_id',2)->select();
|
||||
}
|
||||
// 汇总参数
|
||||
$total_dt = array();
|
||||
$total_dt['total_sum'] = 0;
|
||||
$total_dt['total_win_sum'] = 0;
|
||||
$total_dt['ximaliang'] = 0;
|
||||
$total_dt['total_maliang'] = 0;
|
||||
$total_dt['income'] = 0;
|
||||
|
||||
// 时间条件
|
||||
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);
|
||||
}
|
||||
$this->assign('get',$get);
|
||||
|
||||
foreach($table AS $k => $v){
|
||||
// 注单查询条件
|
||||
$betWhere = array();
|
||||
$betWhere['create_time'] = array('between',[$startTime,$endTime]);
|
||||
$betWhere['table_id'] = $v['id'];
|
||||
$v['status'] = 1;
|
||||
// 洗码查询条件
|
||||
$ximaWhere = array();
|
||||
$ximaWhere['table_id'] = $v['id'];
|
||||
$ximaWhere['status'] = 1;
|
||||
$ximaWhere['type'] = 1;
|
||||
$ximaWhere['ximaliang'] = array('gt',0);
|
||||
$ximaWhere['create_time'] = array('between',[$startTime,$endTime]);
|
||||
// 结果统计查询条件
|
||||
$betCountWhere = array();
|
||||
$betCountWhere['table_id'] = $v['id'];
|
||||
$betCountWhere['start_time'] = array('between',[$startTime,$endTime]);
|
||||
|
||||
//龙下注总额
|
||||
$v['bankerSum'] = Db::name('bet')->where($betWhere)->sum('banker_amount');
|
||||
//虎下注总额
|
||||
$v['playerSum'] = Db::name('bet')->where($betWhere)->sum('player_amount');
|
||||
//和下注总额
|
||||
$v['tieSum'] = Db::name('bet')->where($betWhere)->sum('tie_amount');
|
||||
//龙次数
|
||||
$betCountWhere['result'] = 1;
|
||||
$v['bankerCount'] = Db::name('number_tab')->where($betCountWhere)->count();
|
||||
//虎次数
|
||||
$betCountWhere['result'] = 2;
|
||||
$v['playerCount'] = Db::name('number_tab')->where($betCountWhere)->count();
|
||||
//和次数
|
||||
$betCountWhere['result'] = 3;
|
||||
$v['tieCount'] = Db::name('number_tab')->where($betCountWhere)->count();
|
||||
//总下注金额
|
||||
$v['totalSum'] = $v['bankerSum'] + $v['playerSum'] + $v['tieSum'];
|
||||
//总赢
|
||||
$v['totalWinSum'] = Db::name('bet')->where($betWhere)->sum('win_total');
|
||||
//收益
|
||||
$v['income'] = to_number($v['totalWinSum']);
|
||||
|
||||
$table[$k] = $v;
|
||||
// 汇总参数
|
||||
$total_dt['total_sum'] += $v['totalSum'];
|
||||
$total_dt['total_win_sum'] += $v['totalWinSum'];
|
||||
$total_dt['income'] += $v['income'];
|
||||
}
|
||||
$this->assign('table',$table);
|
||||
$this->assign('total_dt',$total_dt);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function nn_print(){
|
||||
// 接收参数
|
||||
$startDate = Request::instance()->get('startDate');
|
||||
$endDate = Request::instance()->get('endDate');
|
||||
$table_id = Request::instance()->get('table_id');
|
||||
// 查询桌子信息
|
||||
$table_list = Db::name('table')->where('game_id',4)->select();
|
||||
if($table_id > 0){
|
||||
$table = Db::name('table')->where('game_id',4)->where('id',$table_id)->select();
|
||||
}else{
|
||||
$table = Db::name('table')->where('game_id',4)->select();
|
||||
}
|
||||
|
||||
// 定义汇总参数
|
||||
$total_nn = array();
|
||||
$total_nn['total_sum'] = 0;
|
||||
$total_nn['total_win_sum'] = 0;
|
||||
$total_nn['ximaliang'] = 0;
|
||||
$total_nn['total_maliang'] = 0;
|
||||
$total_nn['income'] = 0;
|
||||
|
||||
// 时间条件
|
||||
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);
|
||||
}
|
||||
$this->assign('get',$get);
|
||||
// 拼装数据
|
||||
foreach($table AS $k => $v){
|
||||
// 注单查询条件
|
||||
$betWhere = array();
|
||||
$betWhere['create_time'] = array('between',[$startTime,$endTime]);
|
||||
$betWhere['table_id'] = $v['id'];
|
||||
$v['status'] = 1;
|
||||
// 洗码查询条件
|
||||
$ximaWhere = array();
|
||||
$ximaWhere['table_id'] = $v['id'];
|
||||
$ximaWhere['status'] = 1;
|
||||
$ximaWhere['type'] = 1;
|
||||
$ximaWhere['ximaliang'] = array('gt',0);
|
||||
$ximaWhere['create_time'] = array('between',[$startTime,$endTime]);
|
||||
// 结果统计查询条件
|
||||
$betCountWhere = array();
|
||||
$betCountWhere['table_id'] = $v['id'];
|
||||
$betCountWhere['start_time'] = array('between',[$startTime,$endTime]);
|
||||
|
||||
$v['amount_player_1_Sum'] = Db::name('bet')->where($betWhere)->sum('amount_player_1');
|
||||
$v['amount_player_1_times_Sum'] = Db::name('bet')->where($betWhere)->sum('amount_player_1_times');
|
||||
$v['amount_player_1_banker_Sum'] = Db::name('bet')->where($betWhere)->sum('amount_player_1_banker');
|
||||
$v['amount_player_1_banker_times_Sum'] = Db::name('bet')->where($betWhere)->sum('amount_player_1_banker_times');
|
||||
$v['amount_player_2_Sum'] = Db::name('bet')->where($betWhere)->sum('amount_player_2');
|
||||
$v['amount_player_2_times_Sum'] = Db::name('bet')->where($betWhere)->sum('amount_player_2_times');
|
||||
$v['amount_player_2_banker_Sum'] = Db::name('bet')->where($betWhere)->sum('amount_player_2_banker');
|
||||
$v['amount_player_2_banker_times_Sum'] = Db::name('bet')->where($betWhere)->sum('amount_player_2_banker_times');
|
||||
$v['amount_player_3_Sum'] = Db::name('bet')->where($betWhere)->sum('amount_player_3');
|
||||
$v['amount_player_3_times_Sum'] = Db::name('bet')->where($betWhere)->sum('amount_player_3_times');
|
||||
$v['amount_player_3_banker_Sum'] = Db::name('bet')->where($betWhere)->sum('amount_player_3_banker');
|
||||
$v['amount_player_3_banker_times_Sum'] = Db::name('bet')->where($betWhere)->sum('amount_player_3_banker_times');
|
||||
//闲一次数
|
||||
$win_player_1['win_player_1'] = 1;
|
||||
$v['win_player_1'] = Db::name('number_tab')->where($win_player_1)->count();
|
||||
//闲二次数
|
||||
$win_player_2['win_player_2'] = 1;
|
||||
$v['win_player_2'] = Db::name('number_tab')->where($win_player_2)->count();
|
||||
//闲三次数
|
||||
$win_player_3['win_player_3'] = 1;
|
||||
$v['win_player_3'] = Db::name('number_tab')->where($win_player_3)->count();
|
||||
//庄次数
|
||||
$win_banker['win_player_1'] = 0;
|
||||
$win_banker['win_player_2'] = 0;
|
||||
$win_banker['win_player_2'] = 0;
|
||||
$v['win_banker'] = Db::name('number_tab')->where($win_banker)->count();
|
||||
//总下注金额
|
||||
$v['totalSum'] = $v['amount_player_1_Sum'] + $v['amount_player_1_times_Sum']+ $v['amount_player_1_banker_Sum']+ $v['amount_player_1_banker_times_Sum']+$v['amount_player_2_Sum'] + $v['amount_player_2_times_Sum']+ $v['amount_player_2_banker_Sum']+ $v['amount_player_2_banker_times_Sum']+$v['amount_player_3_Sum'] + $v['amount_player_3_times_Sum']+ $v['amount_player_3_banker_Sum']+ $v['amount_player_3_banker_times_Sum'];
|
||||
//总赢
|
||||
$v['totalWinSum'] = Db::name('bet')->where($betWhere)->sum('win_total');
|
||||
//收益
|
||||
$v['income'] = to_number($v['totalWinSum']);
|
||||
|
||||
$table[$k] = $v;
|
||||
// 汇总参数
|
||||
$total_nn['total_sum'] += $v['totalSum'];
|
||||
$total_nn['total_win_sum'] += $v['totalWinSum'];
|
||||
$total_nn['income'] += $v['income'];
|
||||
}
|
||||
$this->assign('table',$table);
|
||||
$this->assign('total_nn',$total_nn);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function edit_numberTab(){
|
||||
// 接收分页的条件
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get',$get);
|
||||
$this->assign('query',$query);
|
||||
|
||||
// 接收查询条件
|
||||
$get['table_id'] = Request::instance()->get('table_id');
|
||||
$get['number_id'] = Request::instance()->get('number_id');
|
||||
$get['boot_id'] = Request::instance()->get('boot_id');
|
||||
$get['boot_num'] = Request::instance()->get('boot_num');
|
||||
$get['number'] = Request::instance()->get('number');
|
||||
|
||||
|
||||
|
||||
$this->assign('get',$get);
|
||||
// 百家乐所有桌子信息
|
||||
$table_list = Db::name('table')->where('game_id','between',[1,2])->select();
|
||||
|
||||
|
||||
$where = array();
|
||||
$where['result_before_edit'] = array('gt',0);
|
||||
if($get['table_id'] > 0){
|
||||
$where['table_id'] = $get['table_id'];
|
||||
}
|
||||
if($get['number_id']){
|
||||
$where['id'] = $get['number_id'];
|
||||
}
|
||||
if($get['boot_id']){
|
||||
$where['boot_id'] = $get['boot_id'];
|
||||
}
|
||||
if($get['boot_num']){
|
||||
$where['boot_num'] = $get['boot_num'];
|
||||
}
|
||||
if($get['number']){
|
||||
$where['number'] = $get['number'];
|
||||
}
|
||||
$where['game_id'] = array('between',[1,2]);
|
||||
$editData = Db::name('number_tab')->where($where)->order('id DESC')->paginate(100,false,array('query'=>$get));
|
||||
foreach ($editData as $key => $val){
|
||||
if($val['game_id'] == 1){
|
||||
if($val['result'] == 1){
|
||||
$val['after_result'] = '庄';
|
||||
}elseif($val['result'] == 2){
|
||||
$val['after_result'] = '闲';
|
||||
}else{
|
||||
$val['after_result'] = '和';
|
||||
}
|
||||
if($val['pair'] == 1){
|
||||
$val['after_result'] .= ',庄对';
|
||||
}elseif($val['pair'] == 2){
|
||||
$val['after_result'] .= ',闲对';
|
||||
}elseif($val['pair'] == 3){
|
||||
$val['after_result'] .= ',庄闲对';
|
||||
}
|
||||
|
||||
if($val['result_before_edit'] == 1){
|
||||
$val['before_result'] = '庄';
|
||||
}elseif($val['result_before_edit'] == 2){
|
||||
$val['before_result'] = '闲';
|
||||
}else{
|
||||
$val['before_result'] = '和';
|
||||
}
|
||||
if($val['pair_before_edit'] == 1){
|
||||
$val['before_result'] .= ',庄对';
|
||||
}elseif($val['pair_before_edit'] == 2){
|
||||
$val['before_result'] .= ',闲对';
|
||||
}elseif($val['pair_before_edit'] == 3){
|
||||
$val['before_result'] .= ',庄闲对';
|
||||
}
|
||||
}else{
|
||||
if($val['result'] == 1){
|
||||
$val['after_result'] = '龙';
|
||||
}elseif($val['result'] == 2){
|
||||
$val['after_result'] = '虎';
|
||||
}else{
|
||||
$val['after_result'] = '和';
|
||||
}
|
||||
|
||||
if($val['result_before_edit'] == 1){
|
||||
$val['before_result'] = '龙';
|
||||
}elseif($val['result_before_edit'] == 2){
|
||||
$val['before_result'] = '虎';
|
||||
}else{
|
||||
$val['before_result'] = '和';
|
||||
}
|
||||
}
|
||||
$editData[$key] = $val;
|
||||
}
|
||||
$this->assign('editData',$editData);
|
||||
$this->assign('table_list',$table_list);
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\Db;
|
||||
use think\Request;
|
||||
|
||||
class Tip extends Common{
|
||||
public function index(){
|
||||
// 接收分页的条件
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get',$get);
|
||||
$this->assign('query',$query);
|
||||
|
||||
//接收搜索的条件信息
|
||||
$username = Request::instance()->get('username');
|
||||
$export = Request::instance()->get('export');
|
||||
// 拼装搜索条件
|
||||
$where = array();
|
||||
if(!empty($username)) $where['username'] = $username;
|
||||
if($export == 1){
|
||||
$tip_list = Db::name('tip')->where($where)->order('id desc')->select();
|
||||
}else{
|
||||
//获取所有代理信息
|
||||
$tip_list = Db::name('tip')->where($where)->order('id desc')->paginate(15,false,array('query'=>$get));
|
||||
}
|
||||
foreach ($tip_list as $k => $v) {
|
||||
$v['create_time'] = date("Y-m-d H:i",$v['create_time']);
|
||||
$tip_list[$k] = $v;
|
||||
}
|
||||
//导出excel列表
|
||||
if($export == 1){
|
||||
if($tip_list){
|
||||
//重新组合
|
||||
$excelData = array();
|
||||
foreach($tip_list AS $k => $v){
|
||||
$excelData[$k][0] = $v['user_id'];
|
||||
$excelData[$k][1] = $v['username'];
|
||||
$excelData[$k][2] = $v['table_id'];
|
||||
$excelData[$k][3] = $v['table_name'];
|
||||
$excelData[$k][4] = $v['create_time'];
|
||||
$excelData[$k][5] = $v['money'];
|
||||
}
|
||||
$title = array('用户ID','用户账号','桌子ID','桌子名称','打赏时间','打赏金额');
|
||||
$this->exportExcelCore($excelData, '打赏列表', $title);
|
||||
exit('已导出支持列表,请不要重复刷新该页面!');
|
||||
}else{
|
||||
exit('没有可以导出的列表!');
|
||||
}
|
||||
}
|
||||
// 渲染参数和模板
|
||||
$this->assign('tip_list',$tip_list);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function optimum(){
|
||||
$optimum_list = Db::name('optimum')->order('win_money desc')->select();
|
||||
$this->assign('optimum_list',$optimum_list);
|
||||
return $this->fetch();
|
||||
}
|
||||
public function do_add_optimum(){
|
||||
// 接收提交过来的数据
|
||||
$username = Request::instance()->post('username');
|
||||
$win_money = Request::instance()->post('win_money');
|
||||
if( !isset($username) && empty($username) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'账户名不能为空!']));
|
||||
}
|
||||
if( !isset($win_money) && empty($win_money) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'赢钱金额不能为空!']));
|
||||
}
|
||||
// 拼装数据
|
||||
$data = array();
|
||||
$data['username'] = $username;
|
||||
$data['win_money'] = $win_money;
|
||||
$insert_id = Db::name('optimum')->insertGetId($data);
|
||||
if($insert_id){
|
||||
die(json_encode(['code'=>1,'msg'=>'添加成功!']));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'添加失败!']));
|
||||
}
|
||||
}
|
||||
public function do_edit_optimum(){
|
||||
if(Request::instance()->post()){
|
||||
|
||||
// 接收提交过来的数据
|
||||
$id = Request::instance()->post('edit_id');
|
||||
$username = Request::instance()->post('username');
|
||||
$win_money = Request::instance()->post('win_money');
|
||||
// 数据验证
|
||||
if( !isset($username) && empty($username) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'用户账户不能为空!']));
|
||||
}
|
||||
if( !isset($win_money) && empty($win_money) ){
|
||||
die(json_encode(['code'=>0,'msg'=>'赢钱金额不能为空!']));
|
||||
}
|
||||
|
||||
// 拼装数据
|
||||
$data = array();
|
||||
$data['username'] = $username;
|
||||
$data['win_money'] = $win_money;
|
||||
|
||||
$insert_id = Db::name('optimum')->where('id',$id)->update($data);
|
||||
if($insert_id){
|
||||
die(json_encode(['code'=>1,'msg'=>'修改成功!']));
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'修改失败!']));
|
||||
}
|
||||
}else{
|
||||
die(json_encode(['code'=>0,'msg'=>'操作错误!']));
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+848
@@ -0,0 +1,848 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
use think\Request;
|
||||
use think\Db;
|
||||
use think\Session;
|
||||
use think\Cache;
|
||||
|
||||
class Waybill extends Common
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* 百家乐路单展示页面
|
||||
*/
|
||||
public function baccarat()
|
||||
{
|
||||
// 查询百家乐桌子信息
|
||||
$table_list = Db::name('table')->where(array('game_id' => 1, 'is_scavenging' => 0))->select();
|
||||
$table_id_arr = Db::name('table')->where(array('game_id' => 1, 'is_scavenging' => 0))->column('id');
|
||||
// 定义只能查询前7个记账日期
|
||||
$date = get_weeks();
|
||||
|
||||
// 接收分页的数据
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get', $get);
|
||||
$this->assign('query', $query);
|
||||
|
||||
// 接收查询条件
|
||||
$table_id = Request::instance()->get('search_table_id');
|
||||
$boot_id = Request::instance()->get('search_boot_id');
|
||||
$number_id = Request::instance()->get('search_number_id');
|
||||
$startTime = strtotime(Request::instance()->get('startDate'));
|
||||
$endTime = strtotime(Request::instance()->get('endDate'));
|
||||
|
||||
// 定义查询条件
|
||||
$where = array();
|
||||
if ($table_id > 0) {
|
||||
$where['table_id'] = $table_id;
|
||||
}
|
||||
if ($boot_id > 0) {
|
||||
$where['boot_id'] = $boot_id;
|
||||
}
|
||||
if ($number_id > 0) {
|
||||
$where['id'] = $number_id;
|
||||
}
|
||||
if ($startTime > 0 && $endTime > 0){
|
||||
$where['start_time'] = array('between',[$startTime,$endTime]);
|
||||
}
|
||||
$where['bet_status'] = 3; // 已开出结果的铺
|
||||
if($table_id > 0){
|
||||
$number_tab_list = Db::name('number_tab')->where($where)->order('start_time desc,id desc')->paginate(15, false, array('query' => $get));
|
||||
}else{
|
||||
$number_tab_list = Db::name('number_tab')->where($where)->whereIn('table_id',$table_id_arr)->order('start_time desc,id desc')->paginate(15, false, array('query' => $get));
|
||||
}
|
||||
|
||||
// 重新组装数据
|
||||
foreach ($number_tab_list as $k => $v) {
|
||||
$v['start_time'] = date('Y-m-d H:i:s', $v['start_time']);
|
||||
if ($v['result'] == 1) $v['result'] = "庄";
|
||||
if ($v['result'] == 2) $v['result'] = "闲";
|
||||
if ($v['result'] == 3) $v['result'] = "和";
|
||||
if ($v['pair'] == 0) $v['pair'] = null;
|
||||
if ($v['pair'] == 1) $v['pair'] = "庄对";
|
||||
if ($v['pair'] == 2) $v['pair'] = "闲对";
|
||||
if ($v['pair'] == 3) $v['pair'] = "庄闲对";
|
||||
$number_tab_list[$k] = $v;
|
||||
}
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('number_tab_list', $number_tab_list);
|
||||
$this->assign('table_list', $table_list);
|
||||
$this->assign('date', $date);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 龙虎斗路单展示页面
|
||||
*/
|
||||
public function dt()
|
||||
{
|
||||
// 查询百家乐桌子信息
|
||||
$table_list = Db::name('table')->where(array('game_id' => 2, 'is_scavenging' => 0))->select();
|
||||
$table_id_arr = Db::name('table')->where(array('game_id' => 2, 'is_scavenging' => 0))->column('id');
|
||||
|
||||
// 定义只能查询前7个记账日期
|
||||
$date = get_weeks();
|
||||
|
||||
// 接收分页的数据
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get', $get);
|
||||
$this->assign('query', $query);
|
||||
|
||||
// 接收查询条件
|
||||
$table_id = Request::instance()->get('search_table_id');
|
||||
$boot_id = Request::instance()->get('search_boot_id');
|
||||
$number_id = Request::instance()->get('search_number_id');
|
||||
$startTime = strtotime(Request::instance()->get('startDate'));
|
||||
$endTime = strtotime(Request::instance()->get('endDate'));
|
||||
|
||||
// 定义查询条件
|
||||
$where = array();
|
||||
if ($table_id > 0) {
|
||||
$where['table_id'] = $table_id;
|
||||
}
|
||||
if ($boot_id > 0) {
|
||||
$where['boot_id'] = $boot_id;
|
||||
}
|
||||
if ($number_id > 0) {
|
||||
$where['id'] = $number_id;
|
||||
}
|
||||
if ($startTime > 0 && $endTime > 0){
|
||||
$where['start_time'] = array('between',[$startTime,$endTime]);
|
||||
}
|
||||
$where['bet_status'] = 3;
|
||||
if($table_id > 0){
|
||||
$number_tab_list = Db::name('number_tab')->where($where)->order('start_time desc,id desc')->paginate(15, false, array('query' => $get));
|
||||
}else{
|
||||
$number_tab_list = Db::name('number_tab')->where($where)->whereIn('table_id',$table_id_arr)->order('start_time desc,id desc')->paginate(15, false, array('query' => $get));
|
||||
}
|
||||
|
||||
foreach ($number_tab_list as $k => $v) {
|
||||
$v['start_time'] = date('Y-m-d H:i:s', $v['start_time']);
|
||||
if ($v['result'] == 1) $v['result'] = "龙";
|
||||
if ($v['result'] == 2) $v['result'] = "虎";
|
||||
if ($v['result'] == 3) $v['result'] = "和";
|
||||
$number_tab_list[$k] = $v;
|
||||
}
|
||||
|
||||
// 渲染参和模板
|
||||
$this->assign('number_tab_list', $number_tab_list);
|
||||
$this->assign('table_list', $table_list);
|
||||
$this->assign('date', $date);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function add_number_tab(){
|
||||
if(Request::instance()->post()){
|
||||
$post = Request::instance()->post();
|
||||
$game_id = intval(Request::instance()->post('game_id'));
|
||||
$table_id = intval(Request::instance()->post('table_id'));
|
||||
$boot_id = intval(Request::instance()->post('boot_id'));
|
||||
$number_tab_id = intval(Request::instance()->post('number_tab_id'));
|
||||
$result = trim(Request::instance()->post('result'));
|
||||
if($game_id > 0 && $table_id > 0 && $boot_id > 0 && $number_tab_id){
|
||||
$table = Db::name('table')->where(array('id' => $table_id))->find();
|
||||
$resultArray = explode('-',$result);
|
||||
if(intval($resultArray[0]) != 1 && intval($resultArray[0]) != 2 && intval($resultArray[0]) != 3){
|
||||
return json(array('code' => 0, 'msg' => '请选择结果,然后再提交'));
|
||||
}
|
||||
if($table['game_id'] == 1){
|
||||
$number_tab_info = Db::name('number_tab')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'id' => $number_tab_id))->find();
|
||||
if(empty($number_tab_info)){
|
||||
return json(array('code' => 0, 'msg' => '当前铺数据不存在'));
|
||||
}
|
||||
$insertData = array();
|
||||
$insertData['game_id'] = $game_id;
|
||||
$insertData['game_name'] = $number_tab_info['game_name'];
|
||||
$insertData['table_id'] = $table_id;
|
||||
$insertData['table_name'] = $number_tab_info['table_name'];
|
||||
$insertData['sumday_id'] = $number_tab_info['sumday_id'];
|
||||
$insertData['day'] = $number_tab_info['day'];
|
||||
$insertData['boot_id'] = $boot_id;
|
||||
$insertData['boot_num'] = $number_tab_info['boot_num'];
|
||||
$insertData['number'] = intval($number_tab_info['number']) + 1;
|
||||
$insertData['result'] = intval($resultArray[0]);
|
||||
$insertData['pair'] = intval($resultArray[1]);
|
||||
$insertData['start_time'] = $number_tab_info['start_time'];
|
||||
$insertData['end_time'] = $number_tab_info['end_time'];
|
||||
$insertData['bet_status'] = 3;
|
||||
$insertData['bet_start_time'] = $number_tab_info['bet_start_time'];
|
||||
$insertData['bet_end_time'] = $number_tab_info['bet_end_time'];
|
||||
if($table['mode'] == 2){
|
||||
$insertData['win6'] = intval($resultArray[2]);
|
||||
}
|
||||
$insertData['is_add'] = 1;
|
||||
Db::execute("update `cg_number_tab` set `number` = `number` + 1 where `game_id` = ".$game_id." and `table_id` = ".$table_id." and `boot_id` = ".$boot_id." and `number` > ".intval($number_tab_info['number']));
|
||||
Db::name('number_tab')->insert($insertData);
|
||||
return json(array('code' => 1, 'msg' => '修改成功'));
|
||||
}elseif($table['game_id'] == 2){
|
||||
$number_tab_info = Db::name('number_tab')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'id' => $number_tab_id))->find();
|
||||
if(empty($number_tab_info)){
|
||||
return json(array('code' => 0, 'msg' => '当前铺数据不存在'));
|
||||
}
|
||||
$insertData = array();
|
||||
$insertData['game_id'] = $game_id;
|
||||
$insertData['game_name'] = $number_tab_info['game_name'];
|
||||
$insertData['table_id'] = $table_id;
|
||||
$insertData['table_name'] = $number_tab_info['table_name'];
|
||||
$insertData['sumday_id'] = $number_tab_info['sumday_id'];
|
||||
$insertData['day'] = $number_tab_info['day'];
|
||||
$insertData['boot_id'] = $boot_id;
|
||||
$insertData['boot_num'] = $number_tab_info['boot_num'];
|
||||
$insertData['number'] = intval($number_tab_info['number']) + 1;
|
||||
$insertData['result'] = intval($resultArray[0]);
|
||||
$insertData['start_time'] = $number_tab_info['start_time'];
|
||||
$insertData['end_time'] = $number_tab_info['end_time'];
|
||||
$insertData['bet_status'] = 3;
|
||||
$insertData['bet_start_time'] = $number_tab_info['bet_start_time'];
|
||||
$insertData['bet_end_time'] = $number_tab_info['bet_end_time'];
|
||||
$insertData['is_add'] = 1;
|
||||
Db::execute("update `cg_number_tab` set `number` = `number` + 1 where `game_id` = ".$game_id." and `table_id` = ".$table_id." and `boot_id` = ".$boot_id." and `number` > ".intval($number_tab_info['number']));
|
||||
Db::name('number_tab')->insert($insertData);
|
||||
return json(array('code' => 1, 'msg' => '修改成功'));
|
||||
}
|
||||
}else{
|
||||
return json(array('code' => 0, 'msg' => '数据出错,不能修改,请稍后再试'));
|
||||
}
|
||||
}else{
|
||||
die('ERROR');
|
||||
}
|
||||
}
|
||||
|
||||
public function edit_number_tab(){
|
||||
if(Request::instance()->post()){
|
||||
$post = Request::instance()->post();
|
||||
$game_id = intval(Request::instance()->post('game_id'));
|
||||
$table_id = intval(Request::instance()->post('table_id'));
|
||||
$boot_id = intval(Request::instance()->post('boot_id'));
|
||||
$number_tab_id = intval(Request::instance()->post('number_tab_id'));
|
||||
$result = trim(Request::instance()->post('result'));
|
||||
if($game_id > 0 && $table_id > 0 && $boot_id > 0 && $number_tab_id){
|
||||
$table = Db::name('table')->where(array('id' => $table_id))->find();
|
||||
$resultArray = explode('-',$result);
|
||||
if($table['game_id'] == 1){
|
||||
$number_tab_info = Db::name('number_tab')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'id' => $number_tab_id))->find();
|
||||
if(empty($number_tab_info)){
|
||||
return json(array('code' => 0, 'msg' => '数据出错,不能修改,请稍后再试'));
|
||||
}
|
||||
if($table['mode'] == 2){
|
||||
$resultData = array();
|
||||
$resultData['opening'] = intval($resultArray[0]);
|
||||
$resultData['pair'] = intval($resultArray[1]);
|
||||
$resultData['win6'] = intval($resultArray[2]);
|
||||
if($resultData['opening'] > 0 && $resultData['opening'] < 4){
|
||||
$returnInfo = $this->retreated_baccarat_win6($game_id,$table_id,$boot_id,$number_tab_id,$resultData,$number_tab_info);
|
||||
return json($returnInfo);
|
||||
}else{
|
||||
return json(array('code' => 0, 'msg' => '请选择结果,然后再提交'));
|
||||
}
|
||||
}else{
|
||||
$resultData = array();
|
||||
$resultData['opening'] = intval($resultArray[0]);
|
||||
$resultData['pair'] = intval($resultArray[1]);
|
||||
if($resultData['opening'] > 0 && $resultData['opening'] < 4){
|
||||
$returnInfo = $this->retreated_baccarat($game_id,$table_id,$boot_id,$number_tab_id,$resultData,$number_tab_info);
|
||||
return json($returnInfo);
|
||||
}else{
|
||||
return json(array('code' => 0, 'msg' => '请选择结果,然后再提交'));
|
||||
}
|
||||
}
|
||||
}elseif($table['game_id'] == 2){
|
||||
$number_tab_info = Db::name('number_tab')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'id' => $number_tab_id))->find();
|
||||
if(empty($number_tab_info)){
|
||||
return json(array('code' => 0, 'msg' => '数据出错,不能修改,请稍后再试'));
|
||||
}
|
||||
$resultData = array();
|
||||
$resultData['opening'] = intval($resultArray[0]);
|
||||
if($resultData['opening'] > 0 && $resultData['opening'] < 4){
|
||||
$returnInfo = $this->retreated_dt($game_id,$table_id,$boot_id,$number_tab_id,$resultData,$number_tab_info);
|
||||
return json($returnInfo);
|
||||
}else{
|
||||
return json(array('code' => 0, 'msg' => '请选择结果,然后再提交'));
|
||||
}
|
||||
}elseif($table['game_id'] == 4){
|
||||
// 牛牛作废本局 - 取消单局输赢,退回原投注额
|
||||
$number_tab_info = Db::name('number_tab')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'id' => $number_tab_id))->find();
|
||||
if(empty($number_tab_info)){
|
||||
return json(array('code' => 0, 'msg' => '数据出错,不能修改,请稍后再试'));
|
||||
}
|
||||
if($number_tab_info['bet_status'] != 3){
|
||||
return json(array('code' => 0, 'msg' => '该局尚未开出结果,无法作废'));
|
||||
}
|
||||
$returnInfo = $this->retreated_nn($game_id,$table_id,$boot_id,$number_tab_id,$number_tab_info);
|
||||
return json($returnInfo);
|
||||
}
|
||||
}else{
|
||||
return json(array('code' => 0, 'msg' => '数据出错,不能修改,请稍后再试'));
|
||||
}
|
||||
}else{
|
||||
die('ERROR');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 处理龙虎回档
|
||||
* $table_info 桌子的数据
|
||||
* $data 当前回合数据
|
||||
* $serv swoole对象
|
||||
* $connections 链接ID
|
||||
*/
|
||||
function retreated_dt($game_id,$table_id,$boot_id,$number_tab_id,$resultData,$number_tab_info){
|
||||
$lastNumberTabInfo = $number_tab_info;
|
||||
$table_info = Db::name('table')->where('id',$table_id)->find();
|
||||
//首先更新会员账户余额,减去相应的投注额
|
||||
$bets = Db::name('bet')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $lastNumberTabInfo['id'], 'status' => 1))->select();
|
||||
$oBets = $bets;
|
||||
foreach($bets AS $key => $value){
|
||||
$bet_win_total = $value['win_total'];
|
||||
Db::execute("update `cg_user` set `money` = `money` - ".$bet_win_total." where `id`=".$value['user_id']);
|
||||
}
|
||||
//删除上一铺下注、洗码、分成
|
||||
Db::name('bet')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $lastNumberTabInfo['id']))->delete();
|
||||
Db::name('xima')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $lastNumberTabInfo['id']))->delete();
|
||||
Db::name('cs')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $lastNumberTabInfo['id']))->delete();
|
||||
Db::name('agent_commission')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $lastNumberTabInfo['id']))->delete();
|
||||
$opening = $resultData['opening'];
|
||||
Db::name('number_tab')->where(array('id' => $lastNumberTabInfo['id']))->update(array('result' => $opening));
|
||||
//记录修改日志
|
||||
$retreated_log_data = array();
|
||||
$retreated_log_data['mode'] = 1;
|
||||
$retreated_log_data['type'] = 1;
|
||||
$retreated_log_data['create_time'] = time();
|
||||
$retreated_log_data['gamei_id'] = $game_id;
|
||||
$retreated_log_data['table_id'] = $table_id;
|
||||
$retreated_log_data['table_name'] = $lastNumberTabInfo['table_name'];
|
||||
$retreated_log_data['boot_id'] = $boot_id;
|
||||
$retreated_log_data['boot_num'] = $lastNumberTabInfo['boot_num'];
|
||||
$retreated_log_data['number_tab_id'] = $number_tab_id;
|
||||
$retreated_log_data['number'] = $lastNumberTabInfo['number'];
|
||||
$str = '';
|
||||
if($lastNumberTabInfo['result'] == 1) $str = '龙';
|
||||
if($lastNumberTabInfo['result'] == 2) $str = '虎';
|
||||
if($lastNumberTabInfo['result'] == 3) $str = '和';
|
||||
$nstr = '';
|
||||
if($opening == 1) $nstr = '龙';
|
||||
if($opening == 2) $nstr = '虎';
|
||||
if($opening == 3) $nstr = '和';
|
||||
$retreated_log_data['remark'] = '该口原本结果为:'.$str.',更改为:'.$nstr;
|
||||
Db::name('retreated_log')->insert($retreated_log_data);
|
||||
if(!empty($oBets)){
|
||||
foreach($oBets AS $k => $v){
|
||||
$user_info = Db::name('user')->where(array('id' => intval($v['user_id'])))->find();
|
||||
$agent_commission = $user_info['agent_commission_dt'] / 100;
|
||||
if($user_info){
|
||||
$amount = 0;
|
||||
$amount = $v['banker_amount'] + $v['player_amount'] + $v['tie_amount'];
|
||||
$win_money = 0;
|
||||
// 双边洗码
|
||||
$ximaliang = 0;
|
||||
if($user_info['type_xima'] == 1){
|
||||
$ximaliang = $v['banker_amount'] - $v['player_amount'];
|
||||
$ximaliang = abs($ximaliang);
|
||||
}
|
||||
// 龙赢
|
||||
if ($opening == 1) {
|
||||
if($v['banker_amount'] > 0){
|
||||
$win_money = round($v['banker_amount'] * (1 + $user_info['price_dragon']),2) + $win_money;
|
||||
}
|
||||
// 单边洗码
|
||||
if($user_info['type_xima'] == 2){
|
||||
$ximaliang = $v['player_amount'];
|
||||
}
|
||||
}
|
||||
// 虎赢
|
||||
if ($opening == 2) {
|
||||
if($v['player_amount'] > 0){
|
||||
$win_money = round($v['player_amount'] * (1 + $user_info['price_tiger']),2) + $win_money;
|
||||
}
|
||||
// 单边洗码
|
||||
if($user_info['type_xima'] == 2){
|
||||
$ximaliang = $v['banker_amount'];
|
||||
}
|
||||
}
|
||||
// 和
|
||||
if ($opening == 3) {
|
||||
if(DT_HALF == 1){
|
||||
$win_money = round(($v['banker_amount'] + $v['player_amount']) / 2,2) + $win_money;
|
||||
}else{
|
||||
$win_money = $v['banker_amount'] + $v['player_amount'] + $win_money;
|
||||
}
|
||||
$ximaliang = 0;
|
||||
if($v['tie_amount'] > 0){
|
||||
$win_money = $v['tie_amount'] * (1 + $user_info['price_tie_dt']) + $win_money;
|
||||
}
|
||||
}
|
||||
// 计算最终赢钱还是输钱
|
||||
$win_total = $win_money - $amount;
|
||||
//更新user表余额
|
||||
$money = $user_info['money'] + $win_total;
|
||||
Db::name('user')->where(array('id' => $user_info['id']))->update(array('money' => $money));
|
||||
//更新bet表
|
||||
$insertBetData = $v;
|
||||
$insertBetData['result'] = $opening;
|
||||
$insertBetData['win_total'] = $win_total;
|
||||
$insertBetData['is_edit'] = 1;
|
||||
Db::name('bet')->insert($insertBetData);
|
||||
//写入cs表
|
||||
$agent = explode(',', $user_info['agent_parent_id_path']); //切割多个代理ID为数组
|
||||
krsort($agent);
|
||||
$nextCs = 0;
|
||||
$nextMaliang = 0;
|
||||
foreach($agent as $key => $value){
|
||||
$user_path_info = Db::name('user')->where(array('id' => $value))->find();
|
||||
if($user_path_info){
|
||||
$maliang = 0;
|
||||
$ximalv = $user_path_info['agent_ximalv_dt'];
|
||||
$maliang_true = 0;
|
||||
if($ximalv > 0 && $ximaliang > 0){
|
||||
$type = $key == 0 ? 1 : 0;
|
||||
$maliang = round(($ximaliang * $ximalv) / 100,2);
|
||||
$maliang_true = $maliang;
|
||||
if($user_path_info['agent_cs'] > 0 && $user_path_info['share_xima'] == 2){
|
||||
$maliang_true = $maliang - round($maliang * ($user_path_info['agent_cs'] / 100),2);
|
||||
}
|
||||
$net_maliang = $maliang - $nextMaliang;
|
||||
$nextMaliang = $net_maliang + $nextMaliang;
|
||||
$insert_xima_sql = "INSERT INTO `cg_xima` (`user_id`,`bet_user_id`,`bet_id`,`game_id`,`table_id`,`sumday_id`,`day`,`number_tab_id`,`boot_id`,`ximaliang`,`ximalv`,`maliang`,`maliang_true`,`total`,`win_total`,`create_time`,`type`,`net_maliang`) VALUES (".$value.",".$user_info['id'].",".$v['id'].",".$v['game_id'].",".$v['table_id'].",".$v['sumday_id'].",'".$v['day']."',".$v['number_tab_id'].",".$v['boot_id'].",".$ximaliang.",".$ximalv.",".$maliang.",".$maliang_true.",".$amount.",".$win_total.",".time().",".$type.",".$net_maliang.")";
|
||||
Db::execute($insert_xima_sql);
|
||||
}
|
||||
//if($user_path_info['agent_cs'] > 0){
|
||||
$type = $key == 0 ? 1 : 0;
|
||||
$share_amount = to_number(round(($user_path_info['agent_cs'] * $win_total) / 100,2));
|
||||
if($user_path_info['agent_cs'] > 0){
|
||||
$share_amount_true = round(to_number($maliang + $win_total) * ($user_path_info['agent_cs'] / 100),2);
|
||||
}else{
|
||||
$share_amount_true = $maliang;
|
||||
}
|
||||
$net_cs = $share_amount - $nextCs;
|
||||
$nextCs = $net_cs + $nextCs;
|
||||
$insert_cs_sql = "INSERT INTO `cg_cs` (`user_id`,`bet_user_id`,`bet_id`,`game_id`,`table_id`,`number_tab_id`,`boot_id`,`sumday_id`,`day`,`share_amount`,`share_amount_true`,`share_percent`,`total`,`win_total`,`create_time`,`type`,`net_cs`,`maliang`) VALUES (".$value.",".$user_info['id'].",".$v['id'].",".$v['game_id'].",".$v['table_id'].",".$v['number_tab_id'].",".$v['boot_id'].",".$v['sumday_id'].",'".$v['day']."',".$share_amount.",".$share_amount_true.",".$user_path_info['agent_cs'].",".$amount.",".$win_total.",".time().",".$type.",".$net_cs.",".$maliang.")";
|
||||
Db::execute($insert_cs_sql);
|
||||
//}
|
||||
}
|
||||
}
|
||||
// 代理抽水
|
||||
if($opening == 1 && $v['banker_amount'] > 0 && $user_info['agent_commission'] > 0){
|
||||
$parentIdPath = explode(',',$user_info['agent_parent_id_path']);
|
||||
foreach($parentIdPath as $value){
|
||||
$user = Db::name('user')->where('id',$value)->find();
|
||||
$insert_commission_sql = "INSERT INTO `cg_agent_commission` (`user_id`,`username`,`agent_id`,`agent_username`,`game_id`,`game_name`,`table_id`,`table_name`,`boot_id`,`boot_num`,`number_tab_id`,`number`,`bet_id`,`amount`,`agent_commission`,`money_commission`,`result`,`create_time`) VALUES (".$user['id'].",'".$user['username']."',".$user['agent_parent_id'].",'".$user['agent_parent_username']."',2,'龙虎',".$table_info['id'].",'".$table_info['table_name']."',".$v['boot_id'].",".$v['boot_num'].",".$v['number_tab_id'].",".$v['number'].",".$v['id'].",".$v['banker_amount'].",".$agent_commission.",".$v['banker_amount'] * $agent_commission.",".$opening.",".time().")";
|
||||
Db::execute($insert_commission_sql);
|
||||
}
|
||||
}
|
||||
if($opening == 2 && $v['player_amount'] > 0 && $user_info['agent_commission'] > 0){
|
||||
$parentIdPath = explode(',',$user_info['agent_parent_id_path']);
|
||||
foreach($parentIdPath as $value){
|
||||
$user = Db::name('user')->where('id',$value)->find();
|
||||
$insert_commission_sql = "INSERT INTO `cg_agent_commission` (`user_id`,`username`,`agent_id`,`agent_username`,`game_id`,`game_name`,`table_id`,`table_name`,`boot_id`,`boot_num`,`number_tab_id`,`number`,`bet_id`,`amount`,`agent_commission`,`money_commission`,`result`,`create_time`) VALUES (".$user['id'].",'".$user['username']."',".$user['agent_parent_id'].",'".$user['agent_parent_username']."',2,'龙虎',".$table_info['id'].",'".$table_info['table_name']."',".$v['boot_id'].",".$v['boot_num'].",".$v['number_tab_id'].",".$v['number'].",".$v['id'].",".$v['player_amount'].",".$user_info['agent_commission'].",".$v['player_amount'] * $agent_commission.",".$opening.",".time().")";
|
||||
Db::execute($insert_commission_sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return array('code' => 1, 'msg' => '修改成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理百家乐回档
|
||||
* $table_info 桌子的数据
|
||||
* $data 当前回合数据
|
||||
* $serv swoole对象
|
||||
* $connections 链接ID
|
||||
*/
|
||||
private function retreated_baccarat($game_id,$table_id,$boot_id,$number_tab_id,$resultData,$number_tab_info){
|
||||
$lastNumberTabInfo = $number_tab_info;
|
||||
$table_info = Db::name('table')->where('id',$table_id)->find();
|
||||
//首先更新会员账户余额,减去相应的投注额
|
||||
$bets = Db::name('bet')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $lastNumberTabInfo['id'], 'status' => 1))->select();
|
||||
$oBets = $bets;
|
||||
foreach($bets AS $key => $value){
|
||||
$bet_win_total = $value['win_total'];
|
||||
Db::execute("update `cg_user` set `money` = `money` - ".$bet_win_total." where `id`=".$value['user_id']);
|
||||
}
|
||||
//删除上一铺下注、洗码、分成
|
||||
Db::name('bet')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $lastNumberTabInfo['id']))->delete();
|
||||
Db::name('xima')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $lastNumberTabInfo['id']))->delete();
|
||||
Db::name('cs')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $lastNumberTabInfo['id']))->delete();
|
||||
Db::name('agent_commission')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $lastNumberTabInfo['id']))->delete();
|
||||
$opening = $resultData['opening'];
|
||||
$pair = $resultData['pair'];
|
||||
Db::name('number_tab')->where(array('id' => $lastNumberTabInfo['id']))->update(array('result' => $opening, 'pair' => $pair));
|
||||
//记录修改日志
|
||||
$retreated_log_data = array();
|
||||
$retreated_log_data['mode'] = 1;
|
||||
$retreated_log_data['type'] = 1;
|
||||
$retreated_log_data['create_time'] = time();
|
||||
$retreated_log_data['gamei_id'] = $game_id;
|
||||
$retreated_log_data['table_id'] = $table_id;
|
||||
$retreated_log_data['table_name'] = $lastNumberTabInfo['table_name'];
|
||||
$retreated_log_data['boot_id'] = $boot_id;
|
||||
$retreated_log_data['boot_num'] = $lastNumberTabInfo['boot_num'];
|
||||
$retreated_log_data['number_tab_id'] = $number_tab_id;
|
||||
$retreated_log_data['number'] = $lastNumberTabInfo['number'];
|
||||
$str = '';
|
||||
if($lastNumberTabInfo['result'] == 1) $str = '庄';
|
||||
if($lastNumberTabInfo['result'] == 2) $str = '闲';
|
||||
if($lastNumberTabInfo['result'] == 3) $str = '和';
|
||||
if($lastNumberTabInfo['pair'] == 1) $str = $str.'-庄对';
|
||||
if($lastNumberTabInfo['pair'] == 2) $str = $str.'-闲对';
|
||||
if($lastNumberTabInfo['pair'] == 3) $str = $str.'-庄闲对';
|
||||
$nstr = '';
|
||||
if($opening == 1) $nstr = '庄';
|
||||
if($opening == 2) $nstr = '闲';
|
||||
if($opening == 3) $nstr = '和';
|
||||
if($pair == 1) $nstr = $nstr.'-庄对';
|
||||
if($pair == 2) $nstr = $nstr.'-闲对';
|
||||
if($pair == 3) $nstr = $nstr.'-庄闲对';
|
||||
$retreated_log_data['remark'] = '该口原本结果为:'.$str.',更改为:'.$nstr;
|
||||
Db::name('retreated_log')->insert($retreated_log_data);
|
||||
if(!empty($oBets)){
|
||||
foreach($oBets AS $k => $v){
|
||||
$user_info = Db::name('user')->where(array('id' => intval($v['user_id'])))->find();
|
||||
$agent_commission = $user_info['agent_commission'] / 100;
|
||||
if($user_info){
|
||||
$amount = 0;
|
||||
$amount = $v['banker_amount'] + $v['player_amount'] + $v['tie_amount'] + $v['banker_pair_amount'] + $v['player_pair_amount'];
|
||||
$win_money = 0;
|
||||
// 双边洗码
|
||||
$ximaliang = 0;
|
||||
if($user_info['type_xima'] == 1){
|
||||
$ximaliang = $v['banker_amount'] - $v['player_amount'];
|
||||
$ximaliang = abs($ximaliang);
|
||||
}
|
||||
if($opening == 1){
|
||||
// 庄赢
|
||||
if($v['banker_amount'] > 0){
|
||||
if($table_info['mode'] == 1){
|
||||
$win_money = round($v['banker_amount'] * (1 + $user_info['price_banker'] - $agent_commission),2) + $win_money;
|
||||
}else{
|
||||
$win_money = round($v['banker_amount'] * (1 + $user_info['price_banker']),2) + $win_money;
|
||||
}
|
||||
}
|
||||
// 单边洗码
|
||||
if($user_info['type_xima'] == 2){
|
||||
$ximaliang = $v['player_amount'];
|
||||
}
|
||||
}elseif($opening == 2){
|
||||
// 闲赢
|
||||
if($v['player_amount'] > 0){
|
||||
$win_money = $v['player_amount'] * (1 + $user_info['price_player']) + $win_money;
|
||||
}
|
||||
// 单边洗码
|
||||
if($user_info['type_xima'] == 2){
|
||||
$ximaliang = $v['banker_amount'];
|
||||
}
|
||||
}elseif($opening == 3) {
|
||||
$ximaliang = 0;
|
||||
// 和赢
|
||||
if($v['tie_amount'] > 0){
|
||||
$win_money = $v['tie_amount'] * (1 + $user_info['price_tie_baccarat']) + $win_money;
|
||||
}
|
||||
// 开 和,下注庄和闲不扣钱
|
||||
if($v['banker_amount'] > 0 && $v['player_amount'] > 0){
|
||||
$win_money = $v['player_amount'] + $v['banker_amount'] + $win_money;
|
||||
}elseif($v['banker_amount'] > 0){
|
||||
$win_money = $v['banker_amount'] + $win_money;
|
||||
} elseif ($v['player_amount'] > 0){
|
||||
$win_money = $v['player_amount'] + $win_money;
|
||||
}
|
||||
}
|
||||
if($pair == 3){
|
||||
// 计算庄对下注的赢钱金额
|
||||
if ($v['banker_pair_amount'] > 0) {
|
||||
$win_money = $v['banker_pair_amount'] * (1 + $user_info['price_pair']) + $win_money;
|
||||
}
|
||||
//计算闲对下注的赢钱金额
|
||||
if ($v['player_pair_amount'] > 0) {
|
||||
$win_money = $v['player_pair_amount'] * (1 + $user_info['price_pair']) + $win_money;
|
||||
}
|
||||
}elseif($pair == 1){
|
||||
if ($v['banker_pair_amount'] > 0) {
|
||||
$win_money = $v['banker_pair_amount'] * (1 + $user_info['price_pair']) + $win_money;
|
||||
}
|
||||
}elseif($pair == 2){
|
||||
if ($v['player_pair_amount'] > 0) {
|
||||
$win_money = $v['player_pair_amount'] * (1 + $user_info['price_pair']) + $win_money;
|
||||
}
|
||||
}
|
||||
// 计算最终赢钱还是输钱
|
||||
$win_total = $win_money - $amount;
|
||||
//更新user表余额
|
||||
$money = $user_info['money'] + $win_total;
|
||||
Db::name('user')->where(array('id' => $user_info['id']))->update(array('money' => $money));
|
||||
//更新bet表
|
||||
$insertBetData = $v;
|
||||
$insertBetData['result'] = $opening;
|
||||
$insertBetData['pair'] = $pair;
|
||||
$insertBetData['win_total'] = $win_total;
|
||||
$insertBetData['is_edit'] = 1;
|
||||
Db::name('bet')->insert($insertBetData);
|
||||
//写入码率表及cs表
|
||||
$agent = explode(',', $user_info['agent_parent_id_path']);
|
||||
krsort($agent);
|
||||
$nextCs = 0;
|
||||
$nextMaliang = 0;
|
||||
foreach($agent as $key => $value){
|
||||
$user_path_info = Db::name('user')->where(array('id' => $value))->find();
|
||||
if($user_path_info){
|
||||
$maliang = 0;
|
||||
$ximalv = $user_path_info['agent_ximalv'];
|
||||
$maliang_true = 0;
|
||||
if($ximalv > 0 && $ximaliang > 0){
|
||||
$type = $key == 0 ? 1 : 0;
|
||||
$maliang = round(($ximaliang * $ximalv) / 100,2);
|
||||
$maliang_true = $maliang;
|
||||
if($user_path_info['agent_cs'] > 0 && $user_path_info['share_xima'] == 2){
|
||||
$maliang_true = $maliang - round($maliang * ($user_path_info['agent_cs'] / 100),2);
|
||||
}
|
||||
$net_maliang = $maliang - $nextMaliang;
|
||||
$nextMaliang = $net_maliang + $nextMaliang;
|
||||
$insert_xima_sql = "INSERT INTO `cg_xima` (`user_id`,`bet_user_id`,`bet_id`,`game_id`,`table_id`,`sumday_id`,`day`,`number_tab_id`,`boot_id`,`ximaliang`,`ximalv`,`maliang`,`maliang_true`,`total`,`win_total`,`create_time`,`type`,`net_maliang`) VALUES (".$value.",".$user_info['id'].",".$v['id'].",".$v['game_id'].",".$v['table_id'].",".$v['sumday_id'].",'".$v['day']."',".$v['number_tab_id'].",".$v['boot_id'].",".$ximaliang.",".$ximalv.",".$maliang.",".$maliang_true.",".$amount.",".$win_total.",".$lastNumberTabInfo['bet_start_time'].",".$type.",".$net_maliang.")";
|
||||
Db::execute($insert_xima_sql);
|
||||
}
|
||||
//if($user_path_info['agent_cs'] > 0){
|
||||
$type = $key == 0 ? 1 : 0;
|
||||
$share_amount = to_number(($user_path_info['agent_cs'] * $win_total) / 100);
|
||||
if($user_path_info['agent_cs'] > 0){
|
||||
$share_amount_true = round(to_number($maliang + $win_total) * ($user_path_info['agent_cs'] / 100),2);
|
||||
}else{
|
||||
$share_amount_true = $maliang;
|
||||
}
|
||||
$net_cs = $share_amount - $nextCs;
|
||||
$nextCs = $net_cs + $nextCs;
|
||||
$insert_cs_sql = "INSERT INTO `cg_cs` (`user_id`,`bet_user_id`,`bet_id`,`game_id`,`table_id`,`number_tab_id`,`boot_id`,`sumday_id`,`day`,`share_amount`,`share_amount_true`,`share_percent`,`total`,`win_total`,`create_time`,`type`,`net_cs`,`maliang`) VALUES (".$value.",".$user_info['id'].",".$v['id'].",".$v['game_id'].",".$v['table_id'].",".$v['number_tab_id'].",".$v['boot_id'].",".$v['sumday_id'].",'".$v['day']."',".$share_amount.",".$share_amount_true.",".$user_path_info['agent_cs'].",".$amount.",".$win_total.",".$lastNumberTabInfo['bet_start_time'].",".$type.",".$net_cs.",".$maliang.")";
|
||||
Db::execute($insert_cs_sql);
|
||||
//}
|
||||
}
|
||||
}
|
||||
// 代理抽水
|
||||
if($opening == 1 && $v['banker_amount'] > 0 && $user_info['agent_commission'] > 0 ){
|
||||
$parentIdPath = explode(',',$user_info['agent_parent_id_path']);
|
||||
foreach($parentIdPath as $value){
|
||||
$user = Db::name('user')->where('id',$value)->find();
|
||||
$insert_commission_sql = "INSERT INTO `cg_agent_commission` (`user_id`,`username`,`agent_id`,`agent_username`,`game_id`,`game_name`,`table_id`,`table_name`,`boot_id`,`boot_num`,`number_tab_id`,`number`,`bet_id`,`amount`,`agent_commission`,`money_commission`,`result`,`pair`,`create_time`) VALUES (".$user['id'].",'".$user['username']."',".$user['agent_parent_id'].",'".$user['agent_parent_username']."',1,'百家乐',".$table_info['id'].",'".$table_info['table_name']."',".$v['boot_id'].",".$v['boot_num'].",".$v['number_tab_id'].",".$v['number'].",".$v['id'].",".$v['banker_amount'].",".$user_info['agent_commission'].",".$v['banker_amount'] * $agent_commission.",".$opening.",".$pair.",".time().")";
|
||||
Db::execute($insert_commission_sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return array('code' => 1, 'msg' => '修改成功');
|
||||
}
|
||||
/**
|
||||
* 处理百家乐Win6回档
|
||||
* $table_info 桌子的数据
|
||||
* $data 当前回合数据
|
||||
* $serv swoole对象
|
||||
* $connections 链接ID
|
||||
*/
|
||||
function retreated_baccarat_win6($game_id,$table_id,$boot_id,$number_tab_id,$resultData,$number_tab_info){
|
||||
$lastNumberTabInfo = $number_tab_info;
|
||||
//首先更新会员账户余额,减去相应的投注额
|
||||
$bets = Db::name('bet')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $lastNumberTabInfo['id'], 'status' => 1))->select();
|
||||
$oBets = $bets;
|
||||
foreach($bets AS $key => $value){
|
||||
$bet_win_total = $value['win_total'];
|
||||
Db::execute("update `cg_user` set `money` = `money` - ".$bet_win_total." where `id`=".$value['user_id']);
|
||||
}
|
||||
//删除上一铺下注、洗码、分成
|
||||
Db::name('bet')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $lastNumberTabInfo['id']))->delete();
|
||||
Db::name('xima')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $lastNumberTabInfo['id']))->delete();
|
||||
Db::name('cs')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $lastNumberTabInfo['id']))->delete();
|
||||
$opening = $resultData['opening'];
|
||||
$pair = $resultData['pair'];
|
||||
$isWin6 = $resultData['win6'] == 1 ? 1 : 0;
|
||||
Db::name('number_tab')->where(array('id' => $lastNumberTabInfo['id']))->update(array('result' => $opening, 'pair' => $pair, 'win6' => $isWin6));
|
||||
//记录修改日志
|
||||
$retreated_log_data = array();
|
||||
$retreated_log_data['mode'] = 1;
|
||||
$retreated_log_data['type'] = 1;
|
||||
$retreated_log_data['create_time'] = time();
|
||||
$retreated_log_data['gamei_id'] = $game_id;
|
||||
$retreated_log_data['table_id'] = $table_id;
|
||||
$retreated_log_data['table_name'] = $lastNumberTabInfo['table_name'];
|
||||
$retreated_log_data['boot_id'] = $boot_id;
|
||||
$retreated_log_data['boot_num'] = $lastNumberTabInfo['boot_num'];
|
||||
$retreated_log_data['number_tab_id'] = $number_tab_id;
|
||||
$retreated_log_data['number'] = $lastNumberTabInfo['number'];
|
||||
$str = '';
|
||||
if($lastNumberTabInfo['result'] == 1) $str = '庄';
|
||||
if($lastNumberTabInfo['result'] == 2) $str = '闲';
|
||||
if($lastNumberTabInfo['result'] == 3) $str = '和';
|
||||
if($lastNumberTabInfo['pair'] == 1) $str = $str.'-庄对';
|
||||
if($lastNumberTabInfo['pair'] == 2) $str = $str.'-闲对';
|
||||
if($lastNumberTabInfo['pair'] == 3) $str = $str.'-庄闲对';
|
||||
if($lastNumberTabInfo['win6'] == 1) $str = $str.'-赢6';
|
||||
$nstr = '';
|
||||
if($opening == 1) $nstr = '庄';
|
||||
if($opening == 2) $nstr = '闲';
|
||||
if($opening == 3) $nstr = '和';
|
||||
if($pair == 1) $nstr = $nstr.'-庄对';
|
||||
if($pair == 2) $nstr = $nstr.'-闲对';
|
||||
if($pair == 3) $nstr = $nstr.'-庄闲对';
|
||||
if($isWin6 == 1) $nstr = $nstr.'-赢6';
|
||||
$retreated_log_data['remark'] = '该口原本结果为:'.$str.',更改为:'.$nstr;
|
||||
Db::name('retreated_log')->insert($retreated_log_data);
|
||||
if(!empty($oBets)){
|
||||
foreach($oBets AS $k => $v){
|
||||
$user_info = Db::name('user')->field(array('id','money','agent_parent_id_path'))->where(array('id' => intval($v['user_id'])))->find();
|
||||
if($user_info){
|
||||
$amount = 0;
|
||||
$amount = $v['banker_amount'] + $v['player_amount'] + $v['tie_amount'] + $v['banker_pair_amount'] + $v['player_pair_amount'];
|
||||
$win_money = 0;
|
||||
$BPT_ximaliang = 0;
|
||||
if($opening == 1){
|
||||
// 庄赢
|
||||
if($v['banker_amount'] > 0){
|
||||
if($isWin6 === 1){
|
||||
$win_money = $v['banker_amount'] * (1 + 0.5) + $win_money;
|
||||
}else{
|
||||
$win_money = $v['banker_amount'] * (1 + 1) + $win_money;
|
||||
}
|
||||
}
|
||||
$BPT_ximaliang = $v['player_amount'] + $v['tie_amount'];
|
||||
}elseif($opening == 2){
|
||||
// 闲赢
|
||||
if($v['player_amount'] > 0){
|
||||
if($isWin6 === 1){
|
||||
$win_money = $v['player_amount'] * (1 + 0.5) + $win_money;
|
||||
}else{
|
||||
$win_money = $v['player_amount'] * (1 + 1) + $win_money;
|
||||
}
|
||||
}
|
||||
$BPT_ximaliang = $v['banker_amount'] + $v['tie_amount'];
|
||||
}elseif($opening == 3) {
|
||||
// 和赢
|
||||
if($v['tie_amount'] > 0){
|
||||
$win_money = $v['tie_amount'] * (1 + 8) + $win_money;
|
||||
}
|
||||
// 开 和,下注庄和闲不扣钱
|
||||
if($v['banker_amount'] > 0 && $v['player_amount'] > 0){
|
||||
$win_money = $v['player_amount'] + $v['banker_amount'] + $win_money;
|
||||
}elseif($v['banker_amount'] > 0){
|
||||
$win_money = $v['banker_amount'] + $win_money;
|
||||
} elseif ($v['player_amount'] > 0){
|
||||
$win_money = $v['player_amount'] + $win_money;
|
||||
}
|
||||
//$BPT_ximaliang = $v['banker_amount'] + $v['player_amount'];
|
||||
}
|
||||
$PAIR_ximaliang = 0;
|
||||
if($pair == 3){
|
||||
// 计算庄对下注的赢钱金额
|
||||
if ($v['banker_pair_amount'] > 0) {
|
||||
$win_money = $v['banker_pair_amount'] * (1 + 11) + $win_money;
|
||||
}
|
||||
//计算闲对下注的赢钱金额
|
||||
if ($v['player_pair_amount'] > 0) {
|
||||
$win_money = $v['player_pair_amount'] * (1 + 11) + $win_money;
|
||||
}
|
||||
}elseif($pair == 1){
|
||||
if ($v['banker_pair_amount'] > 0) {
|
||||
$win_money = $v['banker_pair_amount'] * (1 + 11) + $win_money;
|
||||
}
|
||||
$PAIR_ximaliang = $PAIR_ximaliang + $v['player_pair_amount'];
|
||||
}elseif($pair == 2){
|
||||
if ($v['player_pair_amount'] > 0) {
|
||||
$win_money = $v['player_pair_amount'] * (1 + 11) + $win_money;
|
||||
}
|
||||
$PAIR_ximaliang = $PAIR_ximaliang + $v['banker_pair_amount'];
|
||||
}else{
|
||||
$PAIR_ximaliang = $v['player_pair_amount'] + $v['banker_pair_amount'];
|
||||
}
|
||||
$ximaliang = $BPT_ximaliang + $PAIR_ximaliang;
|
||||
// 计算最终赢钱还是输钱
|
||||
$win_total = $win_money - $amount;
|
||||
//更新user表余额
|
||||
$money = $user_info['money'] + $win_total;
|
||||
Db::name('user')->where(array('id' => $user_info['id']))->update(array('money' => $money));
|
||||
//更新bet表
|
||||
$insertBetData = $v;
|
||||
$insertBetData['result'] = $opening;
|
||||
$insertBetData['pair'] = $pair;
|
||||
$insertBetData['win_total'] = $win_total;
|
||||
$insertBetData['is_edit'] = 1;
|
||||
Db::name('bet')->insert($insertBetData);
|
||||
//写入cs表
|
||||
$agent = explode(',', $user_info['agent_parent_id_path']); //切割多个代理ID为数组
|
||||
krsort($agent);
|
||||
$nextCs = 0;
|
||||
foreach($agent as $key => $value){
|
||||
$user_path_info = Db::name('user')->where(array('id' => $value))->find();
|
||||
if($user_path_info){
|
||||
if($user_path_info['agent_cs'] > 0){
|
||||
$type = $key == 0 ? 1 : 0;
|
||||
$share_amount = to_number(($user_path_info['agent_cs'] * $win_total) / 100);
|
||||
$share_amount_true = 0;
|
||||
$net_cs = $share_amount - $share_amount;
|
||||
$nextCs = $net_cs + $nextCs;
|
||||
$insert_cs_sql = "INSERT INTO `cg_cs` (`user_id`,`bet_user_id`,`bet_id`,`game_id`,`table_id`,`number_tab_id`,`boot_id`,`sumday_id`,`day`,`share_amount`,`share_amount_true`,`share_percent`,`total`,`win_total`,`create_time`,`type`,`net_cs`) VALUES (".$value.",".$user_info['id'].",".$v['id'].",".$v['game_id'].",".$v['table_id'].",".$v['number_tab_id'].",".$v['boot_id'].",".$v['sumday_id'].",'".$v['day']."',".$share_amount.",".$share_amount_true.",".$user_path_info['agent_cs'].",".$amount.",".$win_total.",".time().",".$type.",".$net_cs.")";
|
||||
Db::execute($insert_cs_sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return array('code' => 1, 'msg' => '修改成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理牛牛作废本局
|
||||
* 作废逻辑:回滚所有用户余额,将bet状态标记为已作废(status=2),删除洗码/分成/代理抽水记录
|
||||
* $game_id 游戏ID (4=牛牛)
|
||||
* $table_id 桌子ID
|
||||
* $boot_id 靴ID
|
||||
* $number_tab_id 铺ID
|
||||
* $number_tab_info 当前铺数据
|
||||
*/
|
||||
function retreated_nn($game_id,$table_id,$boot_id,$number_tab_id,$number_tab_info){
|
||||
$lastNumberTabInfo = $number_tab_info;
|
||||
// 1. 获取该局所有有效下注记录(status=1)
|
||||
$bets = Db::name('bet')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $lastNumberTabInfo['id'], 'status' => 1))->select();
|
||||
if(empty($bets)){
|
||||
return array('code' => 0, 'msg' => '该局没有下注记录,无需作废');
|
||||
}
|
||||
// 2. 回滚用户余额:减去已结算的win_total(赢了的扣回,输了的退回)
|
||||
foreach($bets AS $key => $value){
|
||||
$bet_win_total = $value['win_total'];
|
||||
Db::execute("update `cg_user` set `money` = `money` - ".$bet_win_total." where `id`=".$value['user_id']);
|
||||
}
|
||||
// 3. 将bet记录标记为已作废(status=2),而非删除,保留审计痕迹
|
||||
Db::name('bet')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $lastNumberTabInfo['id'], 'status' => 1))->update(array('status' => 2));
|
||||
// 4. 删除该局的洗码、分成、代理抽水记录
|
||||
Db::name('xima')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $lastNumberTabInfo['id']))->delete();
|
||||
Db::name('cs')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $lastNumberTabInfo['id']))->delete();
|
||||
Db::name('agent_commission')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $lastNumberTabInfo['id']))->delete();
|
||||
// 5. 处理抢庄用户的余额回滚
|
||||
if($lastNumberTabInfo['rob_banker_id'] > 0){
|
||||
$bankerBet = Db::name('bet')->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'number_tab_id' => $lastNumberTabInfo['id'], 'user_id' => $lastNumberTabInfo['rob_banker_id']))->find();
|
||||
if($bankerBet && $bankerBet['status'] != 2){
|
||||
$bet_win_total = $bankerBet['win_total'];
|
||||
Db::execute("update `cg_user` set `money` = `money` - ".$bet_win_total." where `id`=".$bankerBet['user_id']);
|
||||
Db::name('bet')->where(array('id' => $bankerBet['id']))->update(array('status' => 2));
|
||||
}
|
||||
}
|
||||
// 6. 记录作废操作日志
|
||||
$retreated_log_data = array();
|
||||
$retreated_log_data['mode'] = 2; // mode=2 表示作废
|
||||
$retreated_log_data['type'] = 1;
|
||||
$retreated_log_data['create_time'] = time();
|
||||
$retreated_log_data['gamei_id'] = $game_id;
|
||||
$retreated_log_data['table_id'] = $table_id;
|
||||
$retreated_log_data['table_name'] = $lastNumberTabInfo['table_name'];
|
||||
$retreated_log_data['boot_id'] = $boot_id;
|
||||
$retreated_log_data['boot_num'] = $lastNumberTabInfo['boot_num'];
|
||||
$retreated_log_data['number_tab_id'] = $number_tab_id;
|
||||
$retreated_log_data['number'] = $lastNumberTabInfo['number'];
|
||||
$str = '庄:'.$lastNumberTabInfo['result_banker'].' 闲1:'.$lastNumberTabInfo['result_player_1'].' 闲2:'.$lastNumberTabInfo['result_player_2'].' 闲3:'.$lastNumberTabInfo['result_player_3'];
|
||||
$retreated_log_data['remark'] = '牛牛作废本局,原结果为:'.$str.',已退回所有投注额';
|
||||
Db::name('retreated_log')->insert($retreated_log_data);
|
||||
return array('code' => 1, 'msg' => '作废成功,已退回所有投注额');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\Db;
|
||||
use think\Request;
|
||||
use think\Session;
|
||||
|
||||
class Xima extends Common{
|
||||
/**
|
||||
* 可以洗码的会员及列表
|
||||
*/
|
||||
public function index(){
|
||||
Session::set('allowSubmit','YES');
|
||||
// 接收分页的条件
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('get',$get);
|
||||
$this->assign('query',$query);
|
||||
|
||||
// 接收搜索的条件信息
|
||||
$username = Request::instance()->get('username');
|
||||
$startDate = Request::instance()->get('startDate');
|
||||
$endDate = Request::instance()->get('endDate');
|
||||
|
||||
// 时间条件
|
||||
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);
|
||||
}
|
||||
$this->assign('get',$get);
|
||||
|
||||
// 拼装搜索条件
|
||||
$where = array();
|
||||
if(!empty($username)) $where['username'] = $username;
|
||||
$where['is_delete'] = 0;
|
||||
$where['agent'] = 1;
|
||||
$where['agent_parent_id'] = 0;
|
||||
// 获取所有代理信息
|
||||
$agent_list = Db::name('user')->where($where)->order('id desc')->paginate(10,false,array('query'=>$get));
|
||||
// 数据查询条件
|
||||
$sumWhere = array();
|
||||
$sumWhere['create_time'] = array('between',[$startTime,$endTime]);
|
||||
foreach($agent_list AS $k => $v){
|
||||
$sumWhere['user_id'] = $v['id'];
|
||||
$sumWhere['status'] = 1;
|
||||
//洗码量
|
||||
$v['totalXimaliang'] = Db::name('xima')->where($sumWhere)->sum('ximaliang');
|
||||
//码量
|
||||
$v['maliang'] = Db::name('xima')->where($sumWhere)->sum('maliang');
|
||||
//已结码量
|
||||
$v['checkoutMaliang'] = Db::name('xima')->where($sumWhere)->where(array('is_checkout' => 1))->sum('maliang');
|
||||
//未结码量
|
||||
$v['noCheckoutMaliang'] = Db::name('xima')->where(array('user_id'=>$v['id'],'is_checkout' => 0))->sum('maliang');
|
||||
//最后结算时间
|
||||
if($v['last_xima_time'] > 0){
|
||||
$v['last_xima_time'] = date('Y-m-d H:i:s',$v['last_xima_time']);
|
||||
}else{
|
||||
$v['last_xima_time'] = '-';
|
||||
}
|
||||
$agent_list[$k] = $v;
|
||||
}
|
||||
// 渲染变量和模板
|
||||
$this->assign('agent_list',$agent_list);
|
||||
return $this->fetch();
|
||||
}
|
||||
//处理洗码
|
||||
public function do_xima(){
|
||||
$result = array();
|
||||
$user_info = Session::get('user_info');
|
||||
if(Request::instance()->post() && intval(Request::instance()->post('user_id')) > 0){
|
||||
$user_id = intval(Request::instance()->post('user_id'));
|
||||
$find = Db::name('user')->where(array('id' => $user_id, 'status' => 1, 'is_delete' => 0))->find();
|
||||
if(!$find){
|
||||
$result['errorCode'] = 1;
|
||||
$result['errorMessage'] = '账号处于非正常状态,请确保账号正常再进行操作';
|
||||
die(json_encode($result));
|
||||
}
|
||||
if($find['agent_parent_id'] > 0) {
|
||||
$result['errorCode'] = 1;
|
||||
$result['errorMessage'] = '不允许洗码。请联系其经纪人为其洗码。';
|
||||
die(json_encode($result));
|
||||
}
|
||||
$ximaliang_unbalanced = Db::name('xima')->where(array('status' => 1, 'user_id' => $user_id, 'is_checkout' => 0))->sum('ximaliang');
|
||||
$maliang_unbalanced = Db::name('xima')->where(array('status' => 1, 'user_id' => $user_id, 'is_checkout' => 0))->sum('maliang');
|
||||
if($maliang_unbalanced > 0){
|
||||
//防止重复提交
|
||||
$allowSubmit = Session::get('allowSubmit');
|
||||
if($allowSubmit == 'YES'){
|
||||
Session::delete('allowSubmit');
|
||||
}else{
|
||||
Session::delete('allowSubmit');
|
||||
die(json_encode(['errorCode' => 1, 'errorMessage' => "请勿重复提交"]));
|
||||
}
|
||||
//查找下边的会员
|
||||
$uodateRusult = Db::name('xima')->where(array('status' => 1, 'user_id' => $user_id, 'is_checkout' => 0))->update(array('is_checkout' => 1,'checkout_time' => time()));
|
||||
if($uodateRusult){
|
||||
//记录到洗码日志
|
||||
$insertData = array();
|
||||
$insertData['user_id'] = $user_id;
|
||||
$insertData['username'] = $find['username'];
|
||||
$insertData['ximaliang'] = $ximaliang_unbalanced;
|
||||
$insertData['maliang'] = $maliang_unbalanced;
|
||||
if($find['type_xima'] == 1){
|
||||
$insertData['agent_ximalv'] = $find['agent_ximalv'].'/'.$find['agent_ximalv_dt'].'/'.$find['agent_ximalv_nn'];
|
||||
}elseif($user['type_xima'] == 2){
|
||||
$insertData['agent_ximalv'] = $find['agent_ximalv_single'].'/'.$find['agent_ximalv_dt_single'].'/'.$find['agent_ximalv_nn_single'];
|
||||
}else{
|
||||
$insertData['agent_ximalv'] = '0/0/0';
|
||||
}
|
||||
$insertData['create_time'] = time();
|
||||
$insertData['old_money'] = 0;
|
||||
$insertData['new_money'] = 0;
|
||||
$insertData['admin_id'] = $user_info['id'];
|
||||
$insertData['admin_username'] = $user_info['admin'];
|
||||
$insertData['admin_or_agent'] = 1;
|
||||
Db::name('xima_log')->insert($insertData);
|
||||
//上分表增加记录
|
||||
$rechargeData = array();
|
||||
$rechargeData['type'] = 2;
|
||||
$rechargeData['amount'] = $maliang_unbalanced;
|
||||
$rechargeData['mode'] = 1;
|
||||
$rechargeData['agent_or_admin'] = 1;
|
||||
$rechargeData['user_id'] = $user_id;
|
||||
$rechargeData['user_type'] = $find['agent'];
|
||||
$rechargeData['user_agent_level'] = $find['agent_level'];
|
||||
$rechargeData['username_for'] = $find['username'];
|
||||
$rechargeData['nickname_for'] = $find['nickname'];
|
||||
$rechargeData['user_parent_id'] = $find['agent_parent_id'];
|
||||
$rechargeData['admin_id'] = $user_info['id'];
|
||||
$rechargeData['admin_user_name'] = $user_info['admin'];
|
||||
$rechargeData['create_time'] = time();
|
||||
$rechargeData['old_money'] = $find['money'];
|
||||
$rechargeData['new_money'] = $find['money'];
|
||||
$rechargeData['remake'] = '总后台操作洗码';
|
||||
Db::name('recharge')->insert($rechargeData);
|
||||
Db::name('user')->where(array('id' => $user_id))->update(array('last_xima_time' => time()));
|
||||
}
|
||||
$result['errorCode'] = 0;
|
||||
$result['errorMessage'] = '洗码成功';
|
||||
die(json_encode($result));
|
||||
}else{
|
||||
$result['errorCode'] = 1;
|
||||
$result['errorMessage'] = '洗码数目必须大于0';
|
||||
die(json_encode($result));
|
||||
}
|
||||
}else{
|
||||
$result['errorCode'] = 1;
|
||||
$result['errorMessage'] = 'ERROR';
|
||||
die(json_encode($result));
|
||||
}
|
||||
}
|
||||
public function xima_check(){
|
||||
// 接收分页的条件
|
||||
$get = Request::instance()->get();
|
||||
$query = http_build_query($get);
|
||||
$this->assign('query',$query);
|
||||
|
||||
// 接收搜索条件
|
||||
$startDate = Request::instance()->get('startDate');
|
||||
$endDate = Request::instance()->get('endDate');
|
||||
$export = Request::instance()->get('export');
|
||||
$admin_or_agent = intval(Request::instance()->get('admin_or_agent'));
|
||||
|
||||
// 时间条件
|
||||
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);
|
||||
}
|
||||
$this->assign('get',$get);
|
||||
|
||||
// 拼装搜索条件
|
||||
$where = array();
|
||||
$where['create_time'] = array('between',[$startTime,$endTime]);
|
||||
if($admin_or_agent > 0) $where['admin_or_agent'] = $admin_or_agent;
|
||||
|
||||
if($export == 1){
|
||||
$xima_list = Db::name('xima_log')->where($where)->order('create_time desc')->select();
|
||||
}else{
|
||||
// 所有的洗码记录
|
||||
$xima_list = Db::name('xima_log')->where($where)->order('create_time desc')->paginate(10,false,array('query'=>$get));
|
||||
}
|
||||
foreach($xima_list as $k => $v){
|
||||
// 操作人
|
||||
if($v['admin_or_agent'] == 1 ){
|
||||
$v['connection_username'] = $v['admin_username'];
|
||||
$v['admin_or_agent_msg'] = '总台操作';
|
||||
}else{
|
||||
$v['admin_or_agent_msg'] = '代理操作';
|
||||
}
|
||||
// 数据格式转换
|
||||
$v['ximaliang'] = round($v['ximaliang'],2);
|
||||
$v['maliang'] = round($v['maliang'],2);
|
||||
$user = Db::name('user')->where('id',$v['user_id'])->find();
|
||||
$v['agent_ximalv'] = round($user['agent_ximalv'],2).'/'.round($user['agent_ximalv_dt'],2).'/'.round($user['agent_ximalv_nn'],2);
|
||||
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
|
||||
$xima_list[$k] = $v;
|
||||
}
|
||||
|
||||
//导出excel列表
|
||||
if($export == 1){
|
||||
if($xima_list){
|
||||
//重新组合
|
||||
$excelData = array();
|
||||
foreach($xima_list AS $k => $v){
|
||||
$excelData[$k][0] = $v['username'];
|
||||
$excelData[$k][1] = $v['agent_ximalv'];
|
||||
$excelData[$k][2] = $v['ximaliang'];
|
||||
$excelData[$k][3] = $v['maliang'];
|
||||
$excelData[$k][4] = $v['connection_username'];
|
||||
$excelData[$k][5] = $v['create_time'];
|
||||
$excelData[$k][6] = $v['admin_or_agent_msg'];
|
||||
}
|
||||
$title = array('账号','洗码率(百/龙/牛)%','洗码量','洗码费','操作人','洗码时间','备注');
|
||||
if($startDate && $endDate){
|
||||
$this->exportExcelCore($excelData, '洗码记录-'.$startDate."-".$endDate, $title);
|
||||
}else{
|
||||
$this->exportExcelCore($excelData, '洗码记录', $title);
|
||||
}
|
||||
exit('已导出支持列表,请不要重复刷新该页面!');
|
||||
}else{
|
||||
exit('没有可以导出的列表!');
|
||||
}
|
||||
}
|
||||
|
||||
// 渲染参数和模板
|
||||
$this->assign('xima_list',$xima_list);
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user