diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index aa9ee0cc8..a6bf48085 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -1770,4 +1770,27 @@ function data2csv(&$data,$title,$fields){ fclose($fp); //每生成一个文件关闭 die(); } + +//所有支付方式 +function all_pay_way_other($type=false) +{ + + if($type){ + $pay_way[0]=array('key'=>0,'value'=>"平台币"); + } + $pay_way[1]=array('key'=>-1,'value'=>"绑币"); + $pay_way[2]=array('key'=>1,'value'=>"支付宝"); + $pay_way[3]=array('key'=>2,'value'=>"微信"); + $pay_way[7]=array('key'=>7,'value'=>'金猪'); + $pay_way[9]=array('key'=>9,'value'=>"双乾支付-支付宝"); + $pay_way[10]=array('key'=>10,'value'=>"双乾支付-银联"); +// $pay_way[3]=array('key'=>3,'value'=>'微信APP'); +// $pay_way[4]=array('key'=>4,'value'=>'威富通'); + /* $pay_way[4]=array('key'=>5,'value'=>'聚宝云'); */ +// $pay_way[5]=array('key'=>6,'value'=>'汇付宝'); + /* $pay_way[6]=array('key'=>7,'value'=>"苹果支付"); + */ + $pay_way[15]=array('key'=>15,'value'=>'双乾支付-快捷'); + return $pay_way; +} ?> diff --git a/Application/Admin/Controller/AjaxController.class.php b/Application/Admin/Controller/AjaxController.class.php index 3dcc0cc60..2d6092dec 100644 --- a/Application/Admin/Controller/AjaxController.class.php +++ b/Application/Admin/Controller/AjaxController.class.php @@ -83,7 +83,7 @@ class AjaxController extends ThinkController{ if ($sdk_version) { $map['server_version'] = $game_map['sdk_version'] = $sdk_version; }else { - $this->AjaxReturn([]); +// $this->AjaxReturn([]); } $game = M("Game", 'tab_')->where($game_map)->getField('id', true); diff --git a/Application/Admin/Controller/BehaviorLogController.class.php b/Application/Admin/Controller/BehaviorLogController.class.php index 5306bc473..ddfb070e8 100644 --- a/Application/Admin/Controller/BehaviorLogController.class.php +++ b/Application/Admin/Controller/BehaviorLogController.class.php @@ -130,13 +130,13 @@ class BehaviorLogController extends ThinkController $show_data = []; foreach($data as $k => $v) { if($v['tab'] == 'spend') { - $order_detail = M('spend', 'tab_')->field('order_number,pay_time,user_account,promote_account,game_name,pay_amount,pay_way')->where(['pay_order_number' => $v['pay_order_number']])->find(); + $order_detail = M('spend', 'tab_')->field('extend,pay_time,user_account,promote_account,game_name,pay_amount,pay_way')->where(['pay_order_number' => $v['pay_order_number']])->find(); $re_data['pay_time'] = $order_detail['pay_time']; } elseif($v['tab'] == 'deposit') { $order_detail = M('deposit', 'tab_')->field('order_number,create_time,user_account,promote_account,pay_amount,pay_way')->where(['pay_order_number' => $v['pay_order_number']])->find(); $re_data['pay_time'] = $order_detail['create_time']; } - $re_data['order_number'] = !empty($order_detail['order_number']) ? $order_detail['order_number'] : '-'; + $re_data['order_number'] = isset($order_detail['extend']) ? $order_detail['extend'] : '-'; $re_data['user_account'] = $order_detail['user_account']; $re_data['promote_account'] = $order_detail['promote_account']; $re_data['game_name'] = !empty($order_detail['game_name']) ? $order_detail['game_name'] : '-'; diff --git a/Application/Admin/Controller/ConsoleController.class.php b/Application/Admin/Controller/ConsoleController.class.php index 602063e05..3fd04ec0b 100644 --- a/Application/Admin/Controller/ConsoleController.class.php +++ b/Application/Admin/Controller/ConsoleController.class.php @@ -7,6 +7,7 @@ use Admin\Model\SpendModel; use Think\Think; use Base\Tool\Printer; use Base\Service\PromoteService; +use GuzzleHttp\Client; class ConsoleController extends Think { @@ -263,4 +264,43 @@ class ConsoleController extends Think { } } } + + public function testLogin() + { + /* $client = new Client([ + 'base_uri' => 'http://47.111.118.107:9501', + 'timeout' => 10.0, + ]); + $response = $client->post('/game-event/login', [ + 'form_params' => [ + 'user_id' => 28747, + 'game_id' => 153, + 'login_time' => 1577361998 + ] + ]); + $result = (string)$response->getBody(); + echo $result; */ + + $data = [ + 'user_id' => 28747, + 'game_id' => 153, + 'login_time' => 1577361998 + ]; + $client = new Client([ + 'base_uri' => 'http://47.111.118.107:9501', + 'timeout' => 5.0, + ]); + $promise = $client->requestAsync('POST', '/game-event/login', [ + 'form_params' => $data + ]); + $promise->then( + function (ResponseInterface $res) { + echo $res->getStatusCode() . PHP_EOL; + }, + function (RequestException $e) { + echo $e->getMessage() . PHP_EOL; + echo $e->getRequest()->getMethod(); + } + ); + } } diff --git a/Application/Admin/Controller/ExportController.class.php b/Application/Admin/Controller/ExportController.class.php index 931b8da20..2b99a255e 100644 --- a/Application/Admin/Controller/ExportController.class.php +++ b/Application/Admin/Controller/ExportController.class.php @@ -2049,6 +2049,9 @@ class ExportController extends Controller if (isset($params['order_id'])) { $map['tab_game_supersign.order_id'] = $params['order_id']; } + if (isset($params['pay_way'])) { + $map['tab_game_supersign.pay_way'] = $params['pay_way']; + } if (isset($params['account'])) { $map['tab_user.account'] = $params['account']; } @@ -2078,11 +2081,19 @@ class ExportController extends Controller array('device_number', '设备号'), array('game_name', '游戏'), array('pay_time', '购买时间'), - array('super_money', '超级签金额'), + array('pay_way', '支付方式'), + array('pay_price', '超级签金额'), ); - $xlsData = M('game_supersign', 'tab_')->field('tab_game_supersign.id,tab_game_supersign.order_id,tab_user.account,tab_user.promote_account,tab_user.device_number,tab_game.game_name,tab_game_supersign.pay_time')->join('tab_user on tab_game_supersign.user_id = tab_user.id')->join('tab_game on tab_game_supersign.game_id = tab_game.id')->where($map)->order('id DESC')->select(); + $xlsData = M('game_supersign', 'tab_')->field('tab_game_supersign.id,tab_game_supersign.pay_price,tab_game_supersign.pay_way,tab_game_supersign.order_id,tab_user.account,tab_user.promote_account,tab_user.device_number,tab_game.game_name,tab_game_supersign.pay_time')->join('tab_user on tab_game_supersign.user_id = tab_user.id')->join('tab_game on tab_game_supersign.game_id = tab_game.id')->where($map)->order('id DESC')->select(); foreach($xlsData as $k => $v) { $xlsData[$k]['pay_time'] = date('Y-m-d H:i:s',$v['pay_time']); + if($v['pay_way'] == 0) { + $xlsData[$k]['pay_way'] = '未知'; + }elseif ($v['pay_way'] == 1) { + $xlsData[$k]['pay_way'] = '支付宝'; + }elseif ($v['pay_way'] == 2) { + $xlsData[$k]['pay_way'] = '微信'; + } } break; case 24: @@ -2158,6 +2169,7 @@ class ExportController extends Controller $map['tab_repair_pay.create_time'] = array('BETWEEN', [$startTime, $endTime]); } + if(isset($params['type'])) { $map['tab_repair_pay.type'] = $params['type']; } @@ -2451,13 +2463,13 @@ class ExportController extends Controller ->select(); // dd($data); $map2 = array(); - $map2['fgame_id'] = array('egt', 0); - $map2['puid'] = 0; + $map['fgame_id'] = array('egt', 0); + $map['puid'] = 0; setPowerPromoteIds($map2); $data2 = $user->field('fgame_id,count(IF(register_time ' . $today . ',1,null)) as today, - count(IF(register_time ' . $week . ',1,null)) as week, - count(IF(register_time ' . $mounth . ',1,null)) as mounth') + count(IF(register_time ' . $week . ',1,null)) as week, + count(IF(register_time ' . $mounth . ',1,null)) as mounth') ->where($map2) ->group('fgame_id') ->select(); @@ -2548,8 +2560,8 @@ class ExportController extends Controller setPowerPromoteIds($map2); $data2 = $spend ->field('game_id,sum(IF(pay_time ' . $today . ',pay_amount,0)) as today, - sum(IF(pay_time ' . $week . ',pay_amount,0)) as week, - sum(IF(pay_time ' . $mounth . ',pay_amount,0)) as mounth') + sum(IF(pay_time ' . $week . ',pay_amount,0)) as week, + sum(IF(pay_time ' . $mounth . ',pay_amount,0)) as mounth') ->where($map2) ->group('game_id') ->select(); @@ -2642,8 +2654,8 @@ class ExportController extends Controller $data2 = $user ->field('register_way, count(IF(register_time ' . $today . ',1,null)) as today, - count(IF(register_time ' . $week . ',1,null)) as week, - count(IF(register_time ' . $mounth . ',1,null)) as mounth') + count(IF(register_time ' . $week . ',1,null)) as week, + count(IF(register_time ' . $mounth . ',1,null)) as mounth') ->where($map2) ->group('register_way') ->select(); @@ -2729,9 +2741,9 @@ class ExportController extends Controller setPowerPromoteIds($map2); $data2 = $spend ->field('pay_way, - sum(IF(pay_time ' . $today . ',pay_amount,0)) as today, - sum(IF(pay_time ' . $week . ',pay_amount,0)) as week, - sum(IF(pay_time ' . $mounth . ',pay_amount,0)) as mounth') + sum(IF(pay_time ' . $today . ',pay_amount,0)) as today, + sum(IF(pay_time ' . $week . ',pay_amount,0)) as week, + sum(IF(pay_time ' . $mounth . ',pay_amount,0)) as mounth') ->where($map2) ->group('pay_way') ->select(); @@ -2848,7 +2860,7 @@ class ExportController extends Controller } //为数据权限添加 setPowerPromoteIds($map, 'u.promote_id'); - $data = M('promote', 'tab_')->alias('tp1')->field('tp1.account as promote_account,tp1.id, date_format(FROM_UNIXTIME(register_time),"%Y-%m-%d") AS time, count(u.id) as count, + $data = M('promote', 'tab_')->alias('tp1')->field('tp1.account as promote_account,tp1.id, date_format(FROM_UNIXTIME(register_time),"%Y-%m-%d") AS time, count(u.id) as count, count(IF(register_time ' . $today . ',1,null)) as today, count(IF(register_time ' . $week . ',1,null)) as week, count(IF(register_time ' . $mounth . ',1,null)) as mounth') @@ -2868,7 +2880,7 @@ class ExportController extends Controller //官方渠道数据添加 $authorityData = M('user', 'tab_')->alias('u') ->field('date_format(FROM_UNIXTIME(register_time),"%Y-%m-%d") AS time, - count(id) as count, + count(id) as count, count(IF(register_time ' . $today . ',1,null)) as today, count(IF(register_time ' . $week . ',1,null)) as week, count(IF(register_time ' . $mounth . ',1,null)) as mounth') @@ -3440,9 +3452,9 @@ class ExportController extends Controller array('mau','MAU'), ); - if (is_file(RUNTIME_PATH.'/access_data_user.txt')) { + if (is_file(RUNTIME_PATH.'/access_data_user.txt')) { - $filetxt = file_get_contents(RUNTIME_PATH.'/access_data_user.txt'); + $filetxt = file_get_contents(RUNTIME_PATH.'/access_data_user.txt'); $data = json_decode($filetxt,true); @@ -3475,30 +3487,30 @@ class ExportController extends Controller $this->exportExcel($xlsName, $xlsCell, $xlsData); } - /** - * ltv统计 - * @author 鹿文学 - */ - public function ltv($p=1, $start, $end) { - - $xlsName = $_REQUEST['xlsname']; - - $xlsCell = array( - array('date','日期'), - array('total_amt','充值金额'), - array('user_count','活跃用户'), - array('ltv_1','LTV1'), - array('ltv_2','LTV2'), - array('ltv_3','LTV3'), - array('ltv_4','LTV4'), - array('ltv_5','LTV5'), - array('ltv_6','LTV6'), - array('ltv_7','LTV7'), - array('ltv_14','LTV14'), - array('ltv_30','LTV30'), - ); - - $start_time = $start = strtotime($start); + /** + * ltv统计 + * @author 鹿文学 + */ + public function ltv($p=1, $start, $end) { + + $xlsName = $_REQUEST['xlsname']; + + $xlsCell = array( + array('date','日期'), + array('total_amt','充值金额'), + array('user_count','活跃用户'), + array('ltv_1','LTV1'), + array('ltv_2','LTV2'), + array('ltv_3','LTV3'), + array('ltv_4','LTV4'), + array('ltv_5','LTV5'), + array('ltv_6','LTV6'), + array('ltv_7','LTV7'), + array('ltv_14','LTV14'), + array('ltv_30','LTV30'), + ); + + $start_time = $start = strtotime($start); $end_time = $end = strtotime($end) + 86400; if (is_file(RUNTIME_PATH.'/access_data_ltv.txt')) { $filetxt = file_get_contents(RUNTIME_PATH.'/access_data_ltv.txt'); @@ -3869,21 +3881,21 @@ class ExportController extends Controller $xlsName = $_REQUEST['xlsname']; $xlsCell = array( -// array('id','编号'), +// array('id','编号'), array('order_number','订单号'), array('title','商品信息'), -// array('game_name','游戏名称'), -// array('server_name','区服名称'), -// array('small_account','小号账户'), -// array('seller_account','卖家账号'), - //// array('phone','卖家手机号'), +// array('game_name','游戏名称'), +// array('server_name','区服名称'), +// array('small_account','小号账户'), +// array('seller_account','卖家账号'), + //// array('phone','卖家手机号'), array('buyer_account','交易用户'), array('order_price','售价'), array('poundage','手续费'), array('pay_status','状态'), array('order_time','下单时间'), -// array('pay_time','付款时间'), -// array('send_time','发货时间'), +// array('pay_time','付款时间'), +// array('send_time','发货时间'), ); if(!empty($_REQUEST['order_number'])) {$extend['order_number']=array('like','%'.$_REQUEST['order_number'].'%');} @@ -3985,9 +3997,9 @@ class ExportController extends Controller } - if (is_file(RUNTIME_PATH.'/device_data_foldline.txt')) { + if (is_file(RUNTIME_PATH.'/device_data_foldline.txt')) { - $filetxt = file_get_contents(RUNTIME_PATH.'/device_data_foldline.txt'); + $filetxt = file_get_contents(RUNTIME_PATH.'/device_data_foldline.txt'); $xlsData = $data[$key]; @@ -4336,14 +4348,14 @@ class ExportController extends Controller $xlsName = $_REQUEST['xlsname']; -// $xlsCell = array( -// array('user_account','玩家账号'), -// array('game_name','游戏名称'), -// array('server_name','游戏区服'), -// array('user_nickname','角色名'), -// array('login_time','登录时间'), -// array('login_ip','最后登录ip'), -// ); +// $xlsCell = array( +// array('user_account','玩家账号'), +// array('game_name','游戏名称'), +// array('server_name','游戏区服'), +// array('user_nickname','角色名'), +// array('login_time','登录时间'), +// array('login_ip','最后登录ip'), +// ); $xlsCell = array( '玩家账号', @@ -4459,12 +4471,12 @@ class ExportController extends Controller ob_flush(); flush();//必须同时使用 ob_flush() 和flush() 函数来刷新输出缓冲。 } -// $xlsData = []; +// $xlsData = []; exit(); -// $this->exportExcel($xlsName, $xlsCell, $xlsData); +// $this->exportExcel($xlsName, $xlsCell, $xlsData); } @@ -5887,7 +5899,7 @@ class ExportController extends Controller $xlsData = []; -// if(is_array($data)){ +// if(is_array($data)){ if($_REQUEST['type']==2) { $data=$model ->where($map) @@ -5936,9 +5948,9 @@ class ExportController extends Controller $v['grand_account'] = $v['account']; } $v['status'] = get_info_status($v['status'],3); -// $v['business_affairs'] = get_business_affairs_account($v['ba_id']); -// $v['grand_account'] = getTopPromote($v['id'])['id']; -// $v['promote_levels'] = get_promote_levels($v['id']); +// $v['business_affairs'] = get_business_affairs_account($v['ba_id']); +// $v['grand_account'] = getTopPromote($v['id'])['id']; +// $v['promote_levels'] = get_promote_levels($v['id']); switch ($v['ver_status']) { case '1': @@ -5985,7 +5997,7 @@ class ExportController extends Controller } } -// } +// } $this->exportExcel($xlsName, $xlsCell, $xlsData); @@ -6233,15 +6245,15 @@ class ExportController extends Controller $model = M('user','tab_'); -// $xlsCell = array( -// array('account','玩家账号'), -// array('register_time','注册时间'), -// array('login_time','最后登录时间'), -// array('register_type','注册来源'), -// array('register_ip','注册IP'), -// array('login_time','上次登录'), -// array('top_promote','所属推广员'), -// ); +// $xlsCell = array( +// array('account','玩家账号'), +// array('register_time','注册时间'), +// array('login_time','最后登录时间'), +// array('register_type','注册来源'), +// array('register_ip','注册IP'), +// array('login_time','上次登录'), +// array('top_promote','所属推广员'), +// ); $xlsCell = array( '玩家账号','注册时间','最后登录时间','注册来源','注册IP','上次登录','所属推广员', ); @@ -6321,35 +6333,35 @@ class ExportController extends Controller fclose($fp); exit(); -// $data = M()->table("({$data}) as a") +// $data = M()->table("({$data}) as a") // ->field("a.account,a.register_time,a.login_time,a.register_type,a.register_ip,a.top_promote,a.promote_account") // ->join("left join tab_promote on a.top_promote=tab_promote.id") // ->order("a.id desc") // ->select(false); -// var_dump($data);die(); +// var_dump($data);die(); -// $xlsData = []; +// $xlsData = []; -// if(is_array($data)){ +// if(is_array($data)){ // -// foreach($data as $k => $v) { +// foreach($data as $k => $v) { // -// $v['register_time'] = date('Y-m-d H:i:s',$v['register_time']); -// $v['login_time'] = $v['login_time']>0?date('Y-m-d H:i:s',$v['login_time']):'暂无登录'; +// $v['register_time'] = date('Y-m-d H:i:s',$v['register_time']); +// $v['login_time'] = $v['login_time']>0?date('Y-m-d H:i:s',$v['login_time']):'暂无登录'; // -// $v['register_type'] = get_registertype($v['register_type']); +// $v['register_type'] = get_registertype($v['register_type']); // -// $promote = get_parent_promoteto($v['promote_id']); +// $promote = get_parent_promoteto($v['promote_id']); // -// $v['top_promote'] = $promote?($v['promote_account'] . get_parent_promoteto($v['promote_id'])):get_promote_name($v['promote_id']); +// $v['top_promote'] = $promote?($v['promote_account'] . get_parent_promoteto($v['promote_id'])):get_promote_name($v['promote_id']); // -// $xlsData[] = $v; +// $xlsData[] = $v; // -// } +// } // // -// } +// } $this->exportExcel($xlsName, $xlsCell, $xlsData); @@ -6656,22 +6668,22 @@ class ExportController extends Controller $xlsName = $_REQUEST['xlsname']; -// $xlsCell = array( -// array('pay_order_number', "订单号"), -// array('pay_time', "充值时间"), -// array('promote_account', L('Subordinate_channel')), -// array('parent_id', "上级推广员"), -// array('user_account', "玩家账号"), -// array('game_name', "游戏名称"), -// array('server_name', L('Game_area_clothing')), -// array('game_player_name', "角色名"), -// array('spend_ip', "充值ip"), -// array('pay_amount', "应付金额"), -// array('cost', "实付金额"), -// array('pay_way', "充值方式"), -// array('promote_id', '商务专员'), -// array('is_check','对账状态') -// ); +// $xlsCell = array( +// array('pay_order_number', "订单号"), +// array('pay_time', "充值时间"), +// array('promote_account', L('Subordinate_channel')), +// array('parent_id', "上级推广员"), +// array('user_account', "玩家账号"), +// array('game_name', "游戏名称"), +// array('server_name', L('Game_area_clothing')), +// array('game_player_name', "角色名"), +// array('spend_ip', "充值ip"), +// array('pay_amount', "应付金额"), +// array('cost', "实付金额"), +// array('pay_way', "充值方式"), +// array('promote_id', '商务专员'), +// array('is_check','对账状态') +// ); $xlsCell = array( "订单号", "充值时间", L('Subordinate_channel'), "上线推广员", "玩家账号", "游戏名称", L('Game_area_clothing'), @@ -6861,22 +6873,22 @@ class ExportController extends Controller /* 执行查询 */ ->select(false); - // $xlsCell = array( -// array('pay_order_number', "订单号"), -// array('pay_time', "充值时间"), -// array('promote_account', L('Subordinate_channel')), -// array('parent_id', "上级推广员"), -// array('user_account', "玩家账号"), -// array('game_name', "游戏名称"), -// array('server_name', L('Game_area_clothing')), -// array('game_player_name', "角色名"), -// array('spend_ip', "充值ip"), -// array('pay_amount', "应付金额"), -// array('cost', "实付金额"), -// array('pay_way', "充值方式"), -// array('promote_id', '商务专员'), -// array('is_check','对账状态') -// ); + // $xlsCell = array( +// array('pay_order_number', "订单号"), +// array('pay_time', "充值时间"), +// array('promote_account', L('Subordinate_channel')), +// array('parent_id', "上级推广员"), +// array('user_account', "玩家账号"), +// array('game_name', "游戏名称"), +// array('server_name', L('Game_area_clothing')), +// array('game_player_name', "角色名"), +// array('spend_ip', "充值ip"), +// array('pay_amount', "应付金额"), +// array('cost', "实付金额"), +// array('pay_way', "充值方式"), +// array('promote_id', '商务专员'), +// array('is_check','对账状态') +// ); $xlsData = M()->table("({$xlsData}) as a") ->field("a.pay_order_number,a.pay_time,a.promote_account,tab_promote.account as parent_id, @@ -6890,9 +6902,9 @@ class ExportController extends Controller if (!$value['account']) { $value['account'] = "暂无"; } -// $xlsData[$key]['parent_id'] = get_top_promote($value['promote_id'], $value['parent_id']); +// $xlsData[$key]['parent_id'] = get_top_promote($value['promote_id'], $value['parent_id']); $xlsData[$key]['pay_way'] = get_pay_way($value['pay_way']); -// $xlsData[$key]['promote_id'] = get_promote_business_account($value['promote_id']); +// $xlsData[$key]['promote_id'] = get_promote_business_account($value['promote_id']); $xlsData[$key]['is_check'] = get_info_status($value['is_check'], 37); $xlsData[$key]['pay_time'] = date('Y-m-d H:i:s', $value['pay_time']); mb_convert_variables('GBK', 'UTF-8', $value); @@ -7196,7 +7208,7 @@ class ExportController extends Controller $map['_string'] .= " pay_time < {$timeend}"; } - $map['pay_status'] = 1; + $map['pay_game_status'] = 1; if (!empty(I("game_id"))) { $map['game_id'] = I("game_id"); } @@ -7212,6 +7224,7 @@ class ExportController extends Controller $order = "pay_time DESC"; $xlsData = D('spend')->getSpendData($map,$field,$group,$order); +// dd(D("spend")->_sql()); foreach($xlsData as $key => $value) { $xlsData[$key]['pay_way'] = getPayType($value['pay_way']); } diff --git a/Application/Admin/Controller/FinanceController.class.php b/Application/Admin/Controller/FinanceController.class.php index 76b31514d..f3a6da5fb 100644 --- a/Application/Admin/Controller/FinanceController.class.php +++ b/Application/Admin/Controller/FinanceController.class.php @@ -1079,7 +1079,7 @@ class FinanceController extends ThinkController //推广后台 $spreadData = M("coin_pay_order","tab_") - ->field("pay_way,'' as pay_type,sum(real_amount) as pay_amount") + ->field("pay_way,'' as pay_type,sum(pay_amount) as pay_amount") ->where([ 'order_status'=>['egt',1], 'pay_way'=>['egt',1],'pay_time'=>$time diff --git a/Application/Admin/Controller/FinancePromoteController.class.php b/Application/Admin/Controller/FinancePromoteController.class.php index 9e4cf147a..63409d2dc 100644 --- a/Application/Admin/Controller/FinancePromoteController.class.php +++ b/Application/Admin/Controller/FinancePromoteController.class.php @@ -56,19 +56,19 @@ class FinancePromoteController extends AdminController $senddata[$v['p_id']] = $v; }; } - if(array_key_exists(0,$senddata) || $_REQUEST['promote_id']==0){ - $pmap['status']=1; - if($istimeselect){ - $pmap['create_time'] = $istimeselect; - } - $admininside = M("provide_user p","tab_")->field("sum(amount) amount")->where($pmap)->find(); - if($admininside['amount'] >0){ - $senddata[0]['inside_cash_count']= $admininside['amount']; + if(!empty($senddata)){ + if(array_key_exists(0,$senddata) || $_REQUEST['promote_id']==0){ + $pmap['status']=1; + if($istimeselect){ + $pmap['create_time'] = $istimeselect; + } + $admininside = M("provide_user p","tab_")->field("sum(amount) amount")->where($pmap)->find(); + if($admininside['amount'] >0){ + $senddata[0]['inside_cash_count']= $admininside['amount']; + } + } - } - - $data = []; $count =array( "cash_count"=>0, @@ -132,6 +132,9 @@ class FinancePromoteController extends AdminController } } } + if (isset($_REQUEST['company_id'])) { + $map['promote.company_id'] = $_REQUEST['company_id']; + } if($type == "spend"){ if (isset($_REQUEST['game_name']) || isset($_REQUEST['game_type'])) { $map["s.game_id"] = array("in",implode(',', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')) ); @@ -289,6 +292,9 @@ class FinancePromoteController extends AdminController } } } + if (isset($_REQUEST['company_id'])) { + $map['promote.company_id'] = $_REQUEST['company_id']; + } if ($type == "spend") { if (isset($_REQUEST['game_name']) || isset($_REQUEST['game_type'])) { $map["s.game_id"] = array("in",implode(',', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')) ); diff --git a/Application/Admin/Controller/GameController.class.php b/Application/Admin/Controller/GameController.class.php index 2faa1d9e2..5a1cbf4dd 100644 --- a/Application/Admin/Controller/GameController.class.php +++ b/Application/Admin/Controller/GameController.class.php @@ -302,7 +302,7 @@ class GameController extends ThinkController if ($_POST['beta_status'] == 1 && empty($_POST['beta_url'])) { return $this->error("请在Beta按钮开启的情况填写Beta链接"); } - if (!empty($_POST['beta_url']) && !preg_match("/^((https|http|ftp|rtsp|mms)?:\/\/)[^\s]+/i", $_POST['beta_url'])) { + if (!empty($_POST['beta_url']) && !preg_match("/^((https|http|itms-beta)?:\/\/)[^\s]+/i", $_POST['beta_url'])) { return $this->error("请填写正确的Beta链接"); } /*if($_POST['apply_status']==0&&$_POST['game_status']==1){ diff --git a/Application/Admin/Controller/PayChannelController.class.php b/Application/Admin/Controller/PayChannelController.class.php index 0e704efb2..5137e6ebe 100644 --- a/Application/Admin/Controller/PayChannelController.class.php +++ b/Application/Admin/Controller/PayChannelController.class.php @@ -65,6 +65,7 @@ class PayChannelController extends ThinkController //平台币充值金额计算 $coinMap['pay_source'] = 2; $coinMap['extend'] = array('eq',''); + $coinMap['tab_deposit.pay_way'] = array('egt',1); // setPowerPromoteIds($coinMap,'tab_deposit.promote_id'); $coinData = M('pay_info','tab_') @@ -74,12 +75,11 @@ class PayChannelController extends ThinkController ->group("game_id") ->select(); - unset($coinMap['game_id']); +// unset($coinMap['game_id']); //平台币充值 $coinSum = M('deposit','tab_') ->where($coinMap) ->sum('tab_deposit.pay_amount'); -// var_dump($coinSum);die(); $data = array_merge($data,$coinData); $data = $this->unique_multi_array($data,'game_id'); @@ -177,7 +177,7 @@ class PayChannelController extends ThinkController // setPowerPromoteIds($spreadMap,'promote_id'); //推广后台 $spreadData = M("coin_pay_order","tab_") - ->field("0 as game_name,sum(real_amount) as pay_amount,0 as platform_coin,id as test_coin") + ->field("0 as game_name,sum(pay_amount) as pay_amount,0 as platform_coin,id as test_coin") ->where($spreadMap) ->find(); $spreadData['pay_amount'] = $spreadData['pay_amount']?$spreadData['pay_amount']:0; @@ -250,11 +250,18 @@ class PayChannelController extends ThinkController } //汇总数据 - $sumData['pay_amount'] = $sumData['pay_amount'] + $superSignData['pay_amount'] + $bindRechargeData['pay_amount']; - $sumData['platform_coin'] = $sumData['platform_coin'] - $sumData['test_platform_coin'] + - $offcialData['pay_amount'] + $spreadData['pay_amount']; - $sumData['test_coin'] = $sumData['test_coin']+$offcialTestCost+$testSuperSignCost+$sumData['test_platform_coin']; - $sumData['sum'] = $sumData['pay_amount'] +$sumData['test_coin'] + $sumData['platform_coin']; + if ($_REQUEST['game_id']) { + $sumData['platform_coin'] = $sumData['platform_coin'] - $sumData['test_platform_coin']; + $sumData['test_coin'] = $sumData['test_coin']+$sumData['test_platform_coin']; + $sumData['sum'] = $sumData['pay_amount'] +$sumData['test_coin'] + $sumData['platform_coin']; + } else { + $sumData['pay_amount'] = $sumData['pay_amount'] + $superSignData['pay_amount'] + $bindRechargeData['pay_amount']; + $sumData['platform_coin'] = $sumData['platform_coin'] - $sumData['test_platform_coin'] + + $offcialData['pay_amount'] + $spreadData['pay_amount']; + $sumData['test_coin'] = $sumData['test_coin']+$offcialTestCost+$testSuperSignCost+$sumData['test_platform_coin']; + $sumData['sum'] = $sumData['pay_amount'] +$sumData['test_coin'] + $sumData['platform_coin']; + $coinSum = $coinSum + $offcialData['pay_amount'] + $spreadData['pay_amount']+$offcialTestCost; + } if($_REQUEST['export'] == 1) { @@ -276,8 +283,8 @@ class PayChannelController extends ThinkController $payTypeDataExport['pay_amount'] .= $key.':'.$value." "; } } - $payTypeDataExport['pay_amount'] .= "平台币直充金额(2019.12.18号以前的不显示在列表中,此项也不计入充值方式统计):". - ($coinSum + $offcialData['pay_amount'] + $spreadData['pay_amount']+$offcialTestCost); + $payTypeDataExport['pay_amount'] .= "平台币直充总金额(2019.12.18号以前的不显示在列表中,此项也不计入充值方式统计):". + ($coinSum); $channelDataExport['game_name'] = '支付渠道'; foreach($channelData as $key => $value) { @@ -288,6 +295,12 @@ class PayChannelController extends ThinkController unset($sumData['test_platform_coin']); + if ($_REQUEST['game_id']) { + unset($superSignData); + unset($offcialData); + unset($spreadData); + } + db2csv(array_merge(array_merge(array_merge(array_merge( array_merge(array_merge( array_merge($data,[0=>$superSignData]),[0=>$offcialData])),[0=>$spreadData],[0=>$sumData])),[0=>$payTypeDataExport]),[0=>$channelDataExport]),'支付渠道统计导出',$title); @@ -296,8 +309,9 @@ class PayChannelController extends ThinkController $this->meta_title = "支付渠道统计"; $size = $row;//每页显示的记录数 $data = array_slice($data, ($arraypage - 1) * $size, $size); + //平台币直充金额,下面列表 - $this->assign('coinSum',$coinSum + $offcialData['pay_amount'] + $spreadData['pay_amount']+$offcialTestCost); + $this->assign('coinSum',$coinSum); $this->assign('sumData',$sumData); $this->assign('channelData',$channelData); @@ -374,6 +388,26 @@ class PayChannelController extends ThinkController ->where($map) ->group('pay_way') ->select(false); + if ($_REQUEST['game_id']) { + if ($map['pay_way']) { + $map['tab_deposit.pay_way'] = $map['pay_way']; + unset($map['pay_way']); + } + if ($map['create_time']) { + $map['tab_deposit.create_time'] = $map['create_time']; + unset($map['create_time']); + } + $map['tab_deposit.pay_source'] = 2; + $map['tab_pay_info.extend'] = ''; + + $depositData = M('pay_info','tab_') + ->join("inner join tab_deposit on tab_pay_info.order_id=tab_deposit.pay_order_number") + ->field('sum(pay_amount) as pay_amount,tab_deposit.pay_way as pay_way') + ->where($map) + ->group('tab_deposit.pay_way') + ->select(false); +// var_dump($depositData);die(); + } $bindMap['pay_status'] = 1; $bindMap['pay_way'] = array('egt',1); @@ -390,8 +424,14 @@ class PayChannelController extends ThinkController ->where($bindMap) ->select(false); + if(!$_REQUEST['game_id']) { + $sql = "{$channelData} UNION ALL {$depositData} UNION ALL {$superSignDataPay} UNION ALL {$spreadDataPay} UNION ALL {$bindRechargeData}"; + } else { + $sql = "{$channelData} UNION ALL {$depositData}"; + } + //将语句整合起来查询 - $channelData = "select sum(pay_amount) as pay_amount,pay_way from ({$channelData} UNION ALL {$depositData} UNION ALL {$superSignDataPay} UNION ALL {$spreadDataPay} UNION ALL {$bindRechargeData})t group by pay_way;"; + $channelData = "select sum(pay_amount) as pay_amount,pay_way from ({$sql})t group by pay_way;"; // var_dump($channelData);die(); $channelData = M()->query($channelData); @@ -482,7 +522,7 @@ class PayChannelController extends ThinkController // setPowerPromoteIds($spreadMap,'promote_id'); // $spreadMap['pay_way'] = array('egt',1); $coin_pay_order = M('coin_pay_order','tab_') - ->field("pay_order_number,create_time as pay_time,promote_account,pay_amount as cost,real_amount as pay_amount,pay_way") + ->field("pay_order_number,create_time as pay_time,promote_account,pay_amount,real_amount as cost,pay_way") ->where($spreadMap) ->select(false); diff --git a/Application/Admin/Controller/PlatformController.class.php b/Application/Admin/Controller/PlatformController.class.php index cdbf674c5..0774439ec 100644 --- a/Application/Admin/Controller/PlatformController.class.php +++ b/Application/Admin/Controller/PlatformController.class.php @@ -56,7 +56,6 @@ class PlatformController extends ThinkController ->group('fgame_id') ->order('count desc,register_time') ->select(); -// dd($data); $map2 = array(); $map2['fgame_id'] = array('egt', 0); $map2['puid'] = 0; @@ -69,7 +68,6 @@ class PlatformController extends ThinkController ->group('fgame_id') ->select(); $data2 = array_column($data2, null, 'fgame_id'); -// dd($data2); $count = count($data); foreach ($data as $key => $value) { static $i = 0; @@ -139,12 +137,12 @@ class PlatformController extends ThinkController //为数据权限添加 setPowerPromoteIds($map); + $map['game_id'] = array('gt', 0); // var_dump($_REQUEST);exit; if (isset($_REQUEST['game_name']) && $_REQUEST['game_name'] != '') { $map['game_id'] = $_REQUEST['game_name']; unset($_REQUEST['game_name']); } - $map['game_id'] = array('gt', 0); $map['pay_status'] = 1; $today = total(1); $week = total(2); @@ -454,19 +452,73 @@ class PlatformController extends ThinkController $data = M('promote', 'tab_')->alias('tp1') ->field('tp1.account as promote_account,tp1.id, date_format(FROM_UNIXTIME(register_time),"% ") AS time, - count(u.id) as count, + count(u.id) as count') + ->join("tab_promote AS tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp2.id = tp1.id", 'left') + ->join("tab_user as u on tp2.id = u.promote_id", 'left') + ->join($play_info_map ? "tab_user_play_info as upi on upi.user_id = u.id " . $play_info_map : false) + ->where($map) + ->group('tp1.id') + ->order('count desc, register_time') + ->select(); + //今日/本周/本月不变 + $tmap = $map; + if(isset($tmap['register_time'])){ + //获取最大最小 + $tweek = total(2,false); + $tmonth = total(3,false); + //获取最小 + $tmin = 0; + if($tweek[1][0] < $tmonth[1][0]){ + $tmin = $tweek[1][0]; + }else{ + $tmin = $tmonth[1][0]; + } + $tmap['register_time'] = ['between', array($tmin,$tmonth[1][1])]; + } + + $tdata = M('promote', 'tab_')->alias('tp1') + ->field('tp1.account as promote_account,tp1.id, + date_format(FROM_UNIXTIME(register_time),"% ") AS time, count(IF(register_time ' . $today . ',1,null)) as today, count(IF(register_time ' . $week . ',1,null)) as week, count(IF(register_time ' . $mounth . ',1,null)) as mounth') ->join("tab_promote AS tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp2.id = tp1.id", 'left') ->join("tab_user as u on tp2.id = u.promote_id", 'left') ->join($play_info_map ? "tab_user_play_info as upi on upi.user_id = u.id " . $play_info_map : false) - ->where($map) + ->where($tmap) ->group('tp1.id') - ->order('count desc, register_time') + ->order('register_time') ->select(); + + $tmdata = []; + foreach($data as $k=>$v){ + $v['today'] = 0; + $v['week'] = 0; + $v['mounth'] = 0; + $tmdata[$v['id']] = $v; + } + foreach ($tdata as $k => $v) { + + $tmdata[$v['id']]['today'] = $v['today']; + $tmdata[$v['id']]['week'] = $v['week']; + $tmdata[$v['id']]['mounth'] = $v['mounth']; + + if (!$tmdata[$v['id']]['promote_account']) { + $tmdata[$v['id']]['promote_account'] = $v['promote_account']; + $tmdata[$v['id']]['count'] = 0; + } + + + } + $data = []; + foreach($tmdata as $k => $v){ + $data[] = $v; + } + unset($map['tp1.id']); unset($map['tp1.chain']); + unset($tmap['tp1.chain']); + unset($tmap['tp1.chain']); $map['promote_id'] = 0; $authorityData['count'] = 0; @@ -475,13 +527,19 @@ class PlatformController extends ThinkController if ($user_auth_promote_ids == 'all' || in_array('0', explode(",", $user_auth_promote_ids))) { //官方渠道数据添加 $authorityData = M('user', 'tab_')->alias('u') - ->field('date_format(FROM_UNIXTIME(register_time),"%Y-%m-%d") AS time, - count(id) as count, - count(IF(register_time ' . $today . ',1,null)) as today, - count(IF(register_time ' . $week . ',1,null)) as week, - count(IF(register_time ' . $mounth . ',1,null)) as mounth') + ->field('date_format(FROM_UNIXTIME(register_time),"%Y-%m-%d") AS time,count(id) as count') ->where($map) ->find(); + $tauthorityData = M('user', 'tab_')->alias('u') + ->field('date_format(FROM_UNIXTIME(register_time),"%Y-%m-%d") AS time, + count(IF(register_time ' . $today . ',1,null)) as today, + count(IF(register_time ' . $week . ',1,null)) as week, + count(IF(register_time ' . $mounth . ',1,null)) as mounth') + ->where($tmap) + ->find(); + $authorityData['today'] = $tauthorityData['today']; + $authorityData['week'] = $tauthorityData['week']; + $authorityData['mounth'] = $tauthorityData['mounth']; } $authorityData['promote_account'] = "官方渠道"; $authorityData['id'] = "1"; @@ -540,83 +598,99 @@ class PlatformController extends ThinkController $map1['promote_id'] = $map['promote_id'] = array('egt', 0); $spend = M('Spend', 'tab_'); if (!empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { - $map['create_time'] = ['between', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399)]; - $pay_time = " between " . strtotime($_REQUEST['timestart']) . " and " . (strtotime($_REQUEST['timeend']) + 86399) . " "; + $map['pay_time'] = ['between', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399)]; unset($_REQUEST['timestart']); unset($_REQUEST['timeend']); } elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) { - $map['create_time'] = ['between', array(strtotime($_REQUEST['timestart']), time())]; - $pay_time = " between " . strtotime($_REQUEST['timestart']) . " and " . time() . " "; + $map['pay_time'] = ['between', array(strtotime($_REQUEST['timestart']), time())]; unset($_REQUEST['timestart']); } elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { - $map['create_time'] = ['elt', strtotime($_REQUEST['timeend']) + 86399]; - $pay_time = " between 0 and " . (strtotime($_REQUEST['timeend']) + 86399) . " "; + $map['pay_time'] = ['elt', strtotime($_REQUEST['timeend']) + 86399]; unset($_REQUEST['timeend']); } else { - $pay_time = " between 0 and " . time(); + $map['pay_time'] = ['between', array(0, time())]; + // $pay_time = " between 0 and " . time(); } $map1['pay_status'] = $map['pay_status'] = 1; $today = total(1); $week = total(2); $mounth = total(3); unset( $map['create_time']); + // var_dump( $promote); + $tweek = total(2,false); + $tmonth = total(3,false); + //获取最小 + $tmin = 0; + if($tweek[1][0] < $tmonth[1][0]){ + $tmin = $tweek[1][0]; + }else{ + $tmin = $tmonth[1][0]; + } - //获取所有会长 - $promote_map = "`chain` = '/'"; + //为数据权限添加 + setPowerPromoteIds($map, 'tp1.id'); + if (isset($_REQUEST['promote_id'])) { - $promote_map = "`chain` = '%/{$_REQUEST['promote_id']}/%' OR id = {$_REQUEST['promote_id']}"; + $map['tp1.id'] = $_REQUEST['promote_id']; + } else { + $map['tp1.chain'] = '/'; } - //为数据权限添加 - setPowerPromoteIds($map); - $promote_map2 = array(); - setPowerPromoteIds($promote_map2, 'id'); - $promote = M("promote","tab_")->field("id,account")->page($page,$row)->where($promote_map)->where($promote_map2)->select(); - $pcount = M("promote","tab_")->field("count(*) acount")->where($promote_map)->where($promote_map2)->find()['acount']; - - // var_dump( $promote); - $data =array(); - for ($i=0; $i < count($promote); $i++) { - # code... - $proid = M("promote","tab_")->field("id")->where("`chain` like '%/{$promote[$i]['id']}/%'")->select(); - $str = ''; - for($k=0; $kfield(' - floor(sum(IF(pay_time ' . $pay_time . ',pay_amount,0))*100) as count, - floor(sum(IF(pay_time ' . $today . ',pay_amount,0))*100) as today, - floor(sum(IF(pay_time ' . $week . ',pay_amount,0))*100) as week, - floor(sum(IF(pay_time ' . $mounth . ',pay_amount,0))*100) as mounth') - ->where($map) - ->where("pay_time".$pay_time) - ->find(); - $dbdata['promote_account'] = $promote[$i]['account']; - $dbdata['promote_id'] = $promote[$i]['id']; - } else { - $dbdata = $spend - ->field(' - floor(sum(IF(pay_time ' . $pay_time . ',pay_amount,0))*100) as count, - floor(sum(IF(pay_time ' . $today . ',pay_amount,0))*100) as today, - floor(sum(IF(pay_time ' . $week . ',pay_amount,0))*100) as week, - floor(sum(IF(pay_time ' . $mounth . ',pay_amount,0))*100) as mounth') - ->where($map) - ->where("pay_time".$pay_time) - ->find(); - $dbdata['promote_account'] = $promote[$i]['account']; - $dbdata['promote_id'] = $promote[$i]['id']; + } + $data = M('promote', 'tab_')->alias('tp1') + ->field('tp1.account as promote_account,tp1.id, + floor(sum(pay_amount)*100) as count') + ->join("tab_promote AS tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp2.id = tp1.id", 'left') + ->join("tab_spend as s on tp2.id = s.promote_id", 'left') + ->where($map) + ->group('tp1.id') + ->order('count desc') + ->select(); + //今日/本周/本月不变 + $tmap = $map; + if(isset($map['pay_time'])){ + $tmap['pay_time'] = ['between', array($tmin,$tmonth[1][1])]; + } + $tdata = M('promote', 'tab_')->alias('tp1') + ->field('tp1.account as promote_account,tp1.id, + floor(sum(IF(s.pay_time ' . $today . ',pay_amount,0))*100) as today, + floor(sum(IF(s.pay_time ' . $week . ',pay_amount,0))*100) as week, + floor(sum(IF(s.pay_time ' . $mounth . ',pay_amount,0))*100) as mounth') + ->join("tab_promote AS tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp2.id = tp1.id", 'left') + ->join("tab_spend as s on tp2.id = s.promote_id", 'left') + ->where($tmap) + ->group('tp1.id') + ->select(); + $tmdata = []; + foreach($data as $k=>$v){ + $v['today'] = 0; + $v['week'] = 0; + $v['mounth'] = 0; + $tmdata[$v['id']] = $v; + } + foreach ($tdata as $k => $v) { + + $tmdata[$v['id']]['today'] = $v['today']; + $tmdata[$v['id']]['week'] = $v['week']; + $tmdata[$v['id']]['mounth'] = $v['mounth']; + if (!$tmdata[$v['id']]['promote_account']) { + $tmdata[$v['id']]['promote_account'] = $v['promote_account']; + $tmdata[$v['id']]['count'] = 0; } - $data[] = $dbdata; } + $data = []; + foreach($tmdata as $k => $v){ + $data[] = $v; + } + // dd($data); + $count = count($data); foreach ($data as $key => $value) { $value['count'] ?: 0; @@ -641,7 +715,7 @@ class PlatformController extends ThinkController $this->assign('userarpu_order_type', $data_order_type); } - $page = set_pagination($pcount, $row); + $page = set_pagination($count, $row); if ($page) { $this->assign('_page', $page); } @@ -650,13 +724,24 @@ class PlatformController extends ThinkController $size = $row;//每页显示的记录数 $pnum = ceil(count($data) / $size); //总页数,ceil()函数用于求大于数字的最小整数 + if(isset($_REQUEST['export'])){ + data2csv($data,'推广员充值统计',array( + "promote_account"=>"推广员账号", + "count"=>"累计充值", + "rand"=>"排行榜", + "today"=>"今日充值", + "week"=>"本周充值", + "mounth"=>"本月充值", + )); + } + $data = array_slice($data, ($arraypage - 1) * $size, $size); $this->meta_title = '渠道充值统计列表'; $this->assign('list_data', $data); $this->assign("is_admin",is_administrator()); $this->display(); } - function promotepay_statistics_1($p = 0) + public function promotepay_statistics1($p = 0) { $page = intval($p); $page = $page ? $page : 1; //默认显示第一页数据 @@ -669,84 +754,97 @@ class PlatformController extends ThinkController $map1['promote_id'] = $map['promote_id'] = array('egt', 0); $spend = M('Spend', 'tab_'); if (!empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { - $map['create_time'] = ['between', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399)]; - $pay_time = " between " . strtotime($_REQUEST['timestart']) . " and " . (strtotime($_REQUEST['timeend']) + 86399) . " "; + $map['pay_time'] = ['between', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399)]; unset($_REQUEST['timestart']); unset($_REQUEST['timeend']); } elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) { - $map['create_time'] = ['between', array(strtotime($_REQUEST['timestart']), time())]; - $pay_time = " between " . strtotime($_REQUEST['timestart']) . " and " . time() . " "; + $map['pay_time'] = ['between', array(strtotime($_REQUEST['timestart']), time())]; unset($_REQUEST['timestart']); } elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { - $map['create_time'] = ['elt', strtotime($_REQUEST['timeend']) + 86399]; - $pay_time = " between 0 and " . (strtotime($_REQUEST['timeend']) + 86399) . " "; + $map['pay_time'] = ['elt', strtotime($_REQUEST['timeend']) + 86399]; unset($_REQUEST['timeend']); } else { - $pay_time = " between 0 and " . time(); + $map['pay_time'] = ['between', array(0, time())]; + // $pay_time = " between 0 and " . time(); } $map1['pay_status'] = $map['pay_status'] = 1; $today = total(1); $week = total(2); $mounth = total(3); - // $map1['pay_way'] = $map['pay_way'] = array('gt', 0); - - $bindrecharge_data = M('bind_recharge', 'tab_') - ->field('max(id) as id,promote_account,promote_id,create_time as ordertime,date_format(FROM_UNIXTIME(create_time),"%Y-%m-%d") AS time, - floor(sum(IF(create_time ' . $pay_time . ',real_amount,0))*100) as scount, - floor(sum(IF(create_time ' . $today . ',real_amount,0))*100) as today, - floor(sum(IF(create_time ' . $week . ',real_amount,0))*100) as week, - floor(sum(IF(create_time ' . $mounth . ',real_amount,0))*100) as mounth') - ->where($map1) - ->group('promote_id') - ->select(false); - - $deposit_data = M('deposit', 'tab_') - ->field('max(id) as id,promote_account,promote_id,create_time as ordertime,date_format(FROM_UNIXTIME(create_time),"%Y-%m-%d") AS time, - floor(sum(IF(create_time ' . $pay_time . ',pay_amount,0))*100) as scount, - floor(sum(IF(create_time ' . $today . ',pay_amount,0))*100) as today, - floor(sum(IF(create_time ' . $week . ',pay_amount,0))*100) as week, - floor(sum(IF(create_time ' . $mounth . ',pay_amount,0))*100) as mounth') - ->where($map1) - ->group('promote_id') - ->select(false); - if (isset($_REQUEST['game_name'])) { - $map['game_name'] = $_REQUEST['game_name']; - if (isset($_REQUEST['server_id'])) { - $map['server_name'] = $_REQUEST['server_id']; - unset($_REQUEST['server_id']); + unset( $map['create_time']); + + //获取所有会长 + $promote_map = "`chain` = '/'"; + if (isset($_REQUEST['promote_id'])) { + $promote_map = "`chain` = '%/{$_REQUEST['promote_id']}/%' OR id = {$_REQUEST['promote_id']}"; + } + //为数据权限添加 + setPowerPromoteIds($map); + $promote_map2 = array(); + setPowerPromoteIds($promote_map2, 'id'); + $promote = M("promote","tab_")->field("id,account")->page($page,$row)->where($promote_map)->where($promote_map2)->select(); + $pcount = M("promote","tab_")->field("count(*) acount")->where($promote_map)->where($promote_map2)->find()['acount']; + + // var_dump( $promote); + $tweek = total(2,false); + $tmonth = total(3,false); + //获取最小 + $tmin = 0; + if($tweek[1][0] < $tmonth[1][0]){ + $tmin = $tweek[1][0]; + }else{ + $tmin = $tmonth[1][0]; + } + + + $data =array(); + for ($i=0; $i < count($promote); $i++) { + # code... + $proid = M("promote","tab_")->field("id")->where("`chain` like '%/{$promote[$i]['id']}/%'")->select(); + $str = ''; + for($k=0; $kfield('max(id) as id,promote_account,promote_id,pay_time as ordertime,date_format(FROM_UNIXTIME(pay_time),"%Y-%m-%d") AS time, - floor(sum(IF(pay_time ' . $pay_time . ',pay_amount,0))*100) as scount, - floor(sum(IF(pay_time ' . $today . ',pay_amount,0))*100) as today, - floor(sum(IF(pay_time ' . $week . ',pay_amount,0))*100) as week, - floor(sum(IF(pay_time ' . $mounth . ',pay_amount,0))*100) as mounth') - ->where($map) - ->group('promote_id') - ->select(false); - } else { - $data = $spend - ->field('max(id) as id,promote_account,promote_id,pay_time as ordertime,date_format(FROM_UNIXTIME(pay_time),"%Y-%m-%d") AS time, - floor(sum(IF(pay_time ' . $pay_time . ',pay_amount,0))*100) as scount, - floor(sum(IF(pay_time ' . $today . ',pay_amount,0))*100) as today, - floor(sum(IF(pay_time ' . $week . ',pay_amount,0))*100) as week, - floor(sum(IF(pay_time ' . $mounth . ',pay_amount,0))*100) as mounth') + $str .= "{$promote[$i]['id']}"; + $map['promote_id'] = array("in",$str); + if (isset($_REQUEST['game_name'])) { + $map['game_name'] = $_REQUEST['game_name']; + if (isset($_REQUEST['server_id'])) { + $map['server_name'] = $_REQUEST['server_id']; + unset($_REQUEST['server_id']); + } + } + $dbdata = $spend + ->field('floor(sum(IF(pay_time ' . $pay_time . ',pay_amount,0))*100) as count') ->where($map) - // ->union(' (' . $bindrecharge_data . ') ') - // ->union(' (' . $deposit_data . ') ') - ->group('promote_id') - ->select(false); - } - $promote_map = "tp1.`chain` = '/'"; - if (isset($_REQUEST['promote_id'])) { - $promote_map = "tp1.`id` = {$_REQUEST['promote_id']}"; - unset($_REQUEST['promote_id']); + ->find(); + $tmap = $map; + if(isset($map['pay_time'])){ + $tmap['pay_time'] = ['between', array($tmin,$tmonth[1][1])]; + } + $tdbdata = $spend + ->field(' + floor(sum(IF(pay_time ' . $today . ',pay_amount,0))*100) as today, + floor(sum(IF(pay_time ' . $week . ',pay_amount,0))*100) as week, + floor(sum(IF(pay_time ' . $mounth . ',pay_amount,0))*100) as mounth') + ->where($tmap) + ->find(); + $dbdata['today']= $tdbdata['today']; + $dbdata['week']= $tdbdata['week']; + $dbdata['mounth']= $tdbdata['mounth']; + + $dbdata['promote_account'] = $promote[$i]['account']; + $dbdata['promote_id'] = $promote[$i]['id']; + + $data[] = $dbdata; } - $data = $spend->field('t.pid as promote_id,t.promote_account,sum(a.scount) AS count,sum(a.today) AS today,sum(a. WEEK) AS WEEK,sum(a.mounth) AS mounth') - ->join("inner JOIN (SELECT tp2.*, tp1.id AS pid, tp1.account as promote_account FROM tab_promote tp1 LEFT JOIN tab_promote tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') where $promote_map ) AS t ON promote_id = t.id or promote_id = t.pid") - ->where($condition)->table('(' . $data . ') as a')->group('t.pid')->order('count desc,a.ordertime')->select(); $count = count($data); foreach ($data as $key => $value) { + $value['count'] ?: 0; + $value['today'] ?: 0; + $value['week'] ?: 0; + $value['mounth'] ?: 0; static $i = 0; $i++; $data[$key]['rand'] = $i; @@ -754,14 +852,8 @@ class PlatformController extends ThinkController $data[$key]['today'] = $value['today'] / 100; $data[$key]['week'] = $value['week'] / 100; $data[$key]['mounth'] = $value['mounth'] / 100; - /* $adata=$this->day_data('Spend',array('promote_id'=>$value['promote_id'])); - $data[$key]['today']=$adata['today']==''?0:$adata['today']; - $data[$key]['week']=$adata['week']==''?0:$adata['week']; - $data[$key]['mounth']=$adata['mounth']==''?0:$adata['mounth']; */ -// if ($data[$key]['promote_id'] == '0') { -// unset($data[$key]); -// } } + $total = $this->data_total($data); $this->assign('total', $total); if ($_REQUEST['data_order'] != '') { @@ -771,19 +863,20 @@ class PlatformController extends ThinkController $this->assign('userarpu_order_type', $data_order_type); } - $page = set_pagination($count, $row); + $page = set_pagination($pcount, $row); if ($page) { $this->assign('_page', $page); } $data = my_sort($data, $data_order_type, (int)$data_order); + $size = $row;//每页显示的记录数 $pnum = ceil(count($data) / $size); //总页数,ceil()函数用于求大于数字的最小整数 - //用array_slice(array,offset,length) 函数在数组中根据条件取出一段值;array(数组),offset(元素的开始位置),length(组的长度) - $data = array_slice($data, ($arraypage - 1) * $size, $size); $this->meta_title = '渠道充值统计列表'; $this->assign('list_data', $data); + $this->assign("is_admin",is_administrator()); $this->display(); + } public function data_total($data) @@ -909,6 +1002,21 @@ class PlatformController extends ThinkController $this->display(); } + public function getSpendServer(){ + if(isset($_REQUEST['game_name'])){ + $game = M('Game','tab_')->field('id')->where(['game_name'=>$_REQUEST['game_name']])->find(); + $game_id = $game['id']; + + } + if(isset($_REQUEST['game_id'])){ + $game_id = $_REQUEST['game_id']; + } + $map['game_id'] = $game_id; + $map['server_name'] = array('neq',''); + $data = M('server','tab_')->field('server_name,server_id')->where($map)->group('server_name')->select(); + $this->AjaxReturn($data); + } + public function uc_deposit($p = 1) { if (isset($_REQUEST['timestart']) && isset($_REQUEST['timeend'])) { diff --git a/Application/Admin/Controller/PromoteController.class.php b/Application/Admin/Controller/PromoteController.class.php index a76becf9a..b53e4ffc9 100644 --- a/Application/Admin/Controller/PromoteController.class.php +++ b/Application/Admin/Controller/PromoteController.class.php @@ -284,6 +284,9 @@ class PromoteController extends ThinkController if ($this->accountExist($data['account'], $_POST['id'])) { $this->error('该账号已存在'); } + if (empty(I('company_id'))) { + $this->error('请选择推广公司'); + } $pdata = D('Promote')->where($map1)->find(); if ($pdata) { diff --git a/Application/Admin/Controller/PromoteGameRatioController.class.php b/Application/Admin/Controller/PromoteGameRatioController.class.php index 635d62fde..7952b4fa2 100644 --- a/Application/Admin/Controller/PromoteGameRatioController.class.php +++ b/Application/Admin/Controller/PromoteGameRatioController.class.php @@ -146,6 +146,10 @@ class PromoteGameRatioController extends ThinkController if (empty($promoteGameRatio)) { $this->error('参数异常'); } + + $promoteId = $promoteGameRatio['promote_id']; + $this->isWithdraw($promoteId, $save['begin_time']);//是否存在开始时间后已提现数据 + if ($promoteGameRatio['status'] == 1) { $save['last_ratio'] = $promoteGameRatio['ratio']; $save['last_ratio_status'] = 1; @@ -161,6 +165,7 @@ class PromoteGameRatioController extends ThinkController } $promoteId = intval($params['promote_id']); $gameId = intval($params['game_id']); + $this->isWithdraw($promoteId, $save['begin_time']);//是否存在开始时间后已提现数据 $promote = M('promote', 'tab_')->find($promoteId); if (empty($promote) || $promote['level'] != 1) { @@ -217,6 +222,26 @@ class PromoteGameRatioController extends ThinkController } } + private function isWithdraw($promoteId, $beginTime) + { + $promote = M('promote', 'tab_')->find($promoteId); + if (empty($promote)) { + $this->error("数据异常"); + } + if ($promote['level'] != 1) { + $this->error("该推广员不是会长账号,无法执行此操作"); + } + + $withdrawMap['promote_id'] = $promoteId; + $withdrawMap['status'] = ['neq', -2]; + $withdrawMap['settlement_end_time'] = ['egt', $beginTime]; + $withdraw = M('withdraw', 'tab_')->where($withdrawMap)->order('create_time desc')->find(); + if (!empty($withdraw) && $withdraw['status'] != -2) { + $time = date('Y-m-d', $withdraw['create_time']); + $this->error("{$time}之前的订单已经申请提现, 无法变更分成比例,请重新选择开始时间"); + } + } + public function setStatus($status) { $params = I('post.'); @@ -228,6 +253,7 @@ class PromoteGameRatioController extends ThinkController if (empty($status) || !in_array($status, [-1, 1])) { $this->error('操作失败'); } + $time = time(); $map['id'] = ['in', $ids]; $map['status'] = 0; @@ -240,6 +266,32 @@ class PromoteGameRatioController extends ThinkController } $result = D(self::MODEL_NAME)->where($map)->save($save); if ($result) { + if ($status == 1) { + foreach ($ids as $id) { + $promoteGameRatio = D(self::MODEL_NAME)->find($id); + if (!empty($promoteGameRatio)) { + if ($promoteGameRatio['begin_time'] <= strtotime(date('Y-m-d', time()))) { + $promoteId = $promoteGameRatio['promote_id']; + $promoteMap['chain'] = ['like', "/{$promoteId}/%"]; + $promoteIds = M('promote', 'tab_')->where($promoteMap)->getField('id', true); + $promoteIds[] = $promoteId; + + $spendMap['promote_id'] = ['in', $promoteIds]; + $spendMap['game_id'] = $promoteGameRatio['game_id']; + if ($promoteGameRatio['end_time'] > 0) { + $spendMap['pay_time'] = ['between', [$promoteGameRatio['begin_time'], $promoteGameRatio['end_time'] + 3600 * 24 - 1]]; + } else { + $spendMap['pay_time'] = ['egt', $promoteGameRatio['begin_time']]; + } + $spendMap['pay_status'] = 1; + $spendMap['selle_status'] = 0; + + $spendSave['selle_ratio'] = $promoteGameRatio['ratio']; + M('spend', 'tab_')->where($spendMap)->save($spendSave); + } + } + } + } $this->success('操作成功'); } else { $this->error('操作失败'); diff --git a/Application/Admin/Controller/ServerNoticeController.class.php b/Application/Admin/Controller/ServerNoticeController.class.php index 8f6974eb1..e6a893d5c 100644 --- a/Application/Admin/Controller/ServerNoticeController.class.php +++ b/Application/Admin/Controller/ServerNoticeController.class.php @@ -262,13 +262,9 @@ class ServerNoticeController extends ThinkController { $game_map = []; if ($game_name) { $game_map['relation_game_name'] = $game_name; - }else { - $this->AjaxReturn([]); } if ($sdk_version) { $map['server_version'] = $game_map['sdk_version'] = $sdk_version; - }else { - $this->AjaxReturn([]); } $game = M("Game", 'tab_')->where($game_map)->getField('id', true); diff --git a/Application/Admin/Controller/StatisticsController.class.php b/Application/Admin/Controller/StatisticsController.class.php index d7b4b3765..5bb786fd6 100644 --- a/Application/Admin/Controller/StatisticsController.class.php +++ b/Application/Admin/Controller/StatisticsController.class.php @@ -1035,15 +1035,17 @@ class StatisticsController extends ThinkController { $map = " 1=1 "; $game_map = ""; - if (isset($_REQUEST['game_name'])) { + if (isset($_REQUEST['game_name']) && isset($_REQUEST['server_name'])) { $game_ids = implode(',', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')); $map .= " AND game_id in ({$game_ids})"; $game_map = " AND EXISTS (SELECT upi.user_id FROM tab_user_play_info as upi where upi.game_id in ({$game_ids}) AND upi.user_id = u.id "; if (isset($_REQUEST['server_name'])) $game_map .= " AND upi.server_name = '{$_REQUEST['server_name']}' "; $game_map .= ") "; - } - if (isset($_REQUEST['server_name'])) { - $map .= " AND server_name = '{$_REQUEST['server_name']}' "; + } else if (isset($_REQUEST['game_name'])) { + $game_ids = implode(',', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')); + $map .= " AND game_id in ({$game_ids})"; + $game_map = " AND EXISTS (SELECT upi.user_id FROM tab_user_play as upi where upi.game_id in ({$game_ids}) AND upi.user_id = u.id "; + $game_map .= ") "; } // 获取包含的用户id $users = M()->query(" diff --git a/Application/Admin/Controller/SuperStatisticalController.class.php b/Application/Admin/Controller/SuperStatisticalController.class.php index 7e1484ed8..ecab06174 100644 --- a/Application/Admin/Controller/SuperStatisticalController.class.php +++ b/Application/Admin/Controller/SuperStatisticalController.class.php @@ -8,6 +8,12 @@ class SuperStatisticalController extends ThinkController private $ticketList_url = 'https://app.ipa365.com/Kirin/OpenApi/TicketList'; + private $pay_way = [ + 0 => '未知', + 1 => '支付宝', + 2 => '微信', + ]; + public function index() { $params = I('get.'); $startDate = empty($params['timestart']) ? '': $params['timestart']; @@ -126,6 +132,9 @@ class SuperStatisticalController extends ThinkController if (isset($params['order_id'])) { $map['tab_game_supersign.order_id'] = $params['order_id']; } + if (isset($params['pay_way'])) { + $map['tab_game_supersign.pay_way'] = $params['pay_way']; + } if (isset($params['account'])) { $map['tab_user.account'] = $params['account']; } @@ -148,9 +157,12 @@ class SuperStatisticalController extends ThinkController if(isset($params['game_id'])) { $map['tab_game_supersign.game_id'] = $params['game_id']; } - $data = M('game_supersign', 'tab_')->field('tab_game_supersign.id,tab_game_supersign.order_id,tab_user.account,tab_user.promote_account,tab_user.device_number,tab_game.game_name,tab_game_supersign.pay_time,tab_game_supersign.pay_price')->join('tab_user on tab_game_supersign.user_id = tab_user.id')->join('tab_game on tab_game_supersign.game_id = tab_game.id')->where($map)->page($page,$row)->order('id DESC')->select(); + $data = M('game_supersign', 'tab_')->field('tab_game_supersign.id,tab_game_supersign.pay_way,tab_game_supersign.order_id,tab_user.account,tab_user.promote_account,tab_user.device_number,tab_game.game_name,tab_game_supersign.pay_time,tab_game_supersign.pay_price')->join('tab_user on tab_game_supersign.user_id = tab_user.id')->join('tab_game on tab_game_supersign.game_id = tab_game.id')->where($map)->page($page,$row)->order('id DESC')->select(); $count = M('game_supersign', 'tab_')->field('tab_game_supersign.order_id,tab_user.account,tab_user.promote_account,tab_user.device_number,tab_game.game_name,tab_game_supersign.pay_time')->join('tab_user on tab_game_supersign.user_id = tab_user.id')->join('tab_game on tab_game_supersign.game_id = tab_game.id')->where($map)->count(); + foreach($data as $k => $v) { + $data[$k]['pay_way'] = $this->pay_way[$v['pay_way']]; + } $pay_price = M('game_supersign', 'tab_')->field('sum(pay_price) as pay_price')->where($map)->select(); $super_money_all = $pay_price[0]['pay_price'] == '' ? 0 : $pay_price[0]['pay_price']; $page = set_pagination($count, $row); diff --git a/Application/Admin/View/Deposit/lists.html b/Application/Admin/View/Deposit/lists.html index 488c82a12..2f11a20f0 100644 --- a/Application/Admin/View/Deposit/lists.html +++ b/Application/Admin/View/Deposit/lists.html @@ -78,21 +78,21 @@ -
- - - -
-
- -
+ + + + + + + + + + + + + + +
diff --git a/Application/Admin/View/FinancePromote/index.html b/Application/Admin/View/FinancePromote/index.html index 836fdadf4..9f60ea626 100644 --- a/Application/Admin/View/FinancePromote/index.html +++ b/Application/Admin/View/FinancePromote/index.html @@ -239,8 +239,8 @@ {$all_count['all_count']} 游戏查看 - 渠道查看 + href="{:U('FinancePromote/gameStatistics',array_merge(I('get.'),['promote_type'=>1,'p'=>1]))}">游戏查看 + 渠道查看 diff --git a/Application/Admin/View/PayChannel/index.html b/Application/Admin/View/PayChannel/index.html index 195d04db9..983f44e80 100644 --- a/Application/Admin/View/PayChannel/index.html +++ b/Application/Admin/View/PayChannel/index.html @@ -71,7 +71,7 @@