From 258d1fbc1a0be5b2e4eccd0e3846689ea738b051 Mon Sep 17 00:00:00 2001 From: chenxiaojun <956334972@qq.com> Date: Wed, 6 Nov 2019 21:09:27 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=8E=A8=E5=B9=BF=E5=90=8E=E5=8F=B0->?= =?UTF-8?q?=E5=AE=89=E5=85=A8=E5=AF=86=E7=A0=81|=E8=B4=A2=E5=8A=A1?= =?UTF-8?q?=E7=AE=A1=E7=90=86--=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Home/Controller/BaseController.class.php | 13 +- .../Controller/FinanceController.class.php | 425 +++++++++++++++++- .../Controller/GameDivideController.class.php | 3 +- .../Controller/PromoteController.class.php | 202 +++++---- .../Home/View/default/Finance/index.html | 184 ++++++++ .../View/default/Finance/settlementDtl.html | 12 +- .../View/default/Finance/withdrawDtl.html | 223 +++++++++ .../View/default/Finance/withdrawRecord.html | 267 +++++++++++ .../Home/View/default/GameDivide/index.html | 10 +- .../Promote/setChildGamePermission.html | 10 +- .../View/default/Public/promote_base.html | 11 +- .../View/default/Public/verify_password.html | 1 - Data/update.sql | 3 + 13 files changed, 1237 insertions(+), 127 deletions(-) create mode 100644 Application/Home/View/default/Finance/index.html create mode 100644 Application/Home/View/default/Finance/withdrawDtl.html create mode 100644 Application/Home/View/default/Finance/withdrawRecord.html diff --git a/Application/Home/Controller/BaseController.class.php b/Application/Home/Controller/BaseController.class.php index 2fe258555..2cd6ba2c5 100644 --- a/Application/Home/Controller/BaseController.class.php +++ b/Application/Home/Controller/BaseController.class.php @@ -252,7 +252,7 @@ class BaseController extends HomeController } //验证安全密码--视图 - public function verifyPasswordView($modelList, $metaTitle) + public function verifyPasswordView($modelList, $show = true) { $securityCode = empty(session('game_divide_second_pwd')) ? '' : session('game_divide_second_pwd');//安全密码 $model = new \User\Api\PromoteApi(); @@ -260,11 +260,14 @@ class BaseController extends HomeController if ($res) { return true; } + if ($show) { + $this->assign('modelList', $modelList); + $this->assign('meta_title', '安全密码'); + $this->display('Public/verify_password'); + exit; + } - $this->assign('modelList', $modelList); - $this->assign('metaTitle', $metaTitle); - $this->display('Public/verify_password'); - exit; + return false; } //验证安全密码 diff --git a/Application/Home/Controller/FinanceController.class.php b/Application/Home/Controller/FinanceController.class.php index aecbe313c..080955c5f 100644 --- a/Application/Home/Controller/FinanceController.class.php +++ b/Application/Home/Controller/FinanceController.class.php @@ -2,6 +2,7 @@ namespace Home\Controller; +use Base\Model\Model; use OT\DataDictionary; use Base\Repository\PromoteRepository; use Base\Repository\SpendRepository; @@ -12,12 +13,144 @@ use Base\Repository\UserRepository; */ class FinanceController extends BaseController { + //提现状态 + public static $withdrawStatus = [ + -1 => '审核未通过', + 0 => '待审核', + 1 => '汇款中', + 2 => '已汇款', + ]; + + //权限过滤 + private function purview() + { + $this->loginPromote = $this->getLoginPromote(); + if ($this->loginPromote['level'] != 1) { + $this->error('权限异常'); + } + return true; + } + + private function getDayList($beginTime, $endTime) + { + $dayList = []; + do { + $dayList[] = date('Y-m-d', $beginTime); + $beginTime += 24 * 60 * 60; + } while ($beginTime < $endTime); + + return $dayList; + } + + private function assembleRecords($items, $keys, $valueColumn, $keyColumn = 'day') + { + $records = []; + foreach ($keys as $key) { + $value = 0; + foreach ($items as $item) { + if ($item[$keyColumn] == $key) { + $value = $item[$valueColumn]; + } + } + $records[$key] = $value; + } + return $records; + } + + //生成提现单号 + private function produceWithdrawNumber() + { + $prefix = 'WD_'; + $number = ''; + while (true) { + $randomNum = rand(10, 99); + $number = $prefix . time() . $randomNum; + $map['widthdraw_number'] = $number; + $res = M('withdraw', 'tab_')->where($map)->getField('id'); + if (!$res) { + break; + } + } + return $number; + } + + //结算中心 + public function index() + { + //是否是会长 + $this->purview(); + //验证安全密码 + $metaTitle = '结算明细'; + $modelList = ['财务管理', $metaTitle]; + $this->verifyPasswordView($modelList); + + $model = M('spend', 'tab_'); + $thisDay = strtotime(date('Y-m-d')); + $thisMonth = strtotime(date('Y-m')); + $yesterday = strtotime(date('Y-m-d', strtotime('-1 day', time()))); + $nowTime = date('Y-m-d'); + $initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime))); + $initBegTime = empty(I('begtime')) ? $initBegTime : I('begtime'); + $initEndTime = $nowTime; + $initEndTime = empty(I('endtime')) ? $initEndTime : I('endtime'); + $begTime = strtotime($initBegTime); + $endTime = strtotime($initEndTime); + $endTime = $endTime + 3600 * 24; + + $map['chain'] = ['like', $this->loginPromote['chain'] . $this->loginPromote['id'] . '/%']; + $promoteIds = M('promote', 'tab_')->where($map)->getField('id', true); + $promoteIds[] = $this->loginPromote['id']; + $promoteIds = implode(',', $promoteIds); + + $map = []; + $map['pay_status'] = 1; + $map['promote_id'] = ['in', $promoteIds]; + $income = $model->field("sum(if(pay_time < $thisDay, if(selle_ratio > 0, pay_amount * selle_ratio, 0), 0)) as history_income, + sum(if(pay_time >= $thisMonth, if(selle_ratio > 0, pay_amount * selle_ratio, 0), 0)) as this_month_income, + sum(if((pay_time >= $yesterday and pay_time < $thisDay), if(selle_ratio > 0, pay_amount * selle_ratio, 0), 0)) as yesterday_income, + sum(if(pay_time < $thisDay, if(selle_status = 0, pay_amount * selle_ratio, 0), 0)) as balance") + ->where($map) + ->find(); + + foreach ($income as &$value) { + $value = bcdiv($value, 100, 2); + } + + $map['pay_time'] = ['between', [$begTime, $endTime]]; + $dayList = $this->getDayList($begTime, $endTime); + $data = $model->field('FROM_UNIXTIME(pay_time, "%Y-%m-%d") as day, + sum(if(selle_ratio > 0, pay_amount * selle_ratio, 0)) as income') + ->where($map) + ->group('day') + ->select(); + $data = $this->assembleRecords($data, $dayList, 'income'); + foreach ($dayList as $day) { + $date = date('Ymd', strtotime($day)); + $records[] = [ + 'day' => $date, + 'income' => bcdiv($data[$day], 100, 2), + 'url' => U('settlementDtl', array('begtime' => $day, 'endtime' => $day)) + ]; + } + + $this->assign('income', $income); + $this->assign('listData', $records); + $this->assign('initBegTime', $initBegTime); + $this->assign('initEndTime', $initEndTime); + $this->assign('yesterday', date('Y-m-d', $yesterday)); + $this->assign('meta_title', $metaTitle); + $this->display(); + } + + //结算明细 public function settlementDtl() { + //是否是会长 + $this->purview(); //验证安全密码 $metaTitle = '结算明细'; $modelList = ['财务管理', $metaTitle]; - $this->verifyPasswordView($modelList, $metaTitle); + $this->verifyPasswordView($modelList); $model = M('spend', 'tab_'); $page = intval(I('get.p', 1)); @@ -31,7 +164,6 @@ class FinanceController extends BaseController $initEndTime = empty(I('endtime')) ? $initEndTime : I('endtime'); $begTime = strtotime($initBegTime); $endTime = strtotime($initEndTime); - $loginPromote = $this->getLoginPromote(); $parameter['p'] = $page; $parameter['row'] = $row; @@ -39,9 +171,9 @@ class FinanceController extends BaseController $parameter['begtime'] = $initBegTime; $parameter['endtime'] = $initEndTime; - $map['chain'] = ['like', $loginPromote['chain'] . $loginPromote['id'] . '/%']; + $map['chain'] = ['like', $this->loginPromote['chain'] . $this->loginPromote['id'] . '/%']; $ids = M('promote', 'tab_')->where($map)->getField('id', true); - $ids[] = $loginPromote['id']; + $ids[] = $this->loginPromote['id']; $ids = implode(',', $ids); $map = []; @@ -57,22 +189,44 @@ class FinanceController extends BaseController $map['pay_time'] = ['between', [$begTime, $endTime + 86399]]; } - $data = $model->field('pay_order_number,game_name,user_account,promote_account,pay_amount,pay_way,if(selle_ratio >= 0,selle_ratio,0) as selle_ratio,convert(pay_amount*if(selle_ratio >= 0,selle_ratio,0),decimal(10,2)) as income,pay_time,selle_status') + $data = $model->field('pay_order_number,game_name,user_account,promote_account,pay_amount,pay_way,if(selle_ratio >= 0,selle_ratio,0) as selle_ratio,pay_time,selle_status,pay_status,withdraw_id') ->where($map) ->order('id desc') ->page($page, $row) ->select(); $count = $model->where($map)->count(); + //提现状态 + $withdrawIds = []; + foreach ($data as $key => $value) { + if ($value['withdraw_id'] > 0 && !in_array($value['withdraw_id'], $withdrawIds)) { + $withdrawIds[] = $value['withdraw_id']; + } + } + $withdrawStatus = M('withdraw', 'tab_') + ->where(array('id' => ['in', $withdrawIds])) + ->getField('id,status'); + foreach ($data as &$list) { - switch ($list['selle_status']) { - case 0: - $list['selle_status'] = '未提现'; - break; - default: - $list['selle_status'] = ''; - break; + //提现状态 + if ($list['pay_status'] == 1) { + switch ($list['selle_status']) { + case 0: + $list['selle_status'] = '未提现'; + break; + default: + if ($list['withdraw_id'] > 0) { + $list['selle_status'] = FinanceController::$withdrawStatus[$withdrawStatus[$list['withdraw_id']]]; + } else { + $list['selle_status'] = ''; + } + break; + } + } else { + $list['selle_status'] = '支付失败'; } + + $list['income'] = bcmul($list['pay_amount'], bcdiv($list['selle_ratio'], 100, 2), 2); $list['pay_time'] = date('Y-m-d H:i:s', $list['pay_time']); } @@ -83,7 +237,252 @@ class FinanceController extends BaseController $this->assign('initBegTime', $initBegTime); $this->assign('initEndTime', $initEndTime); $this->assign('_page', $page); - $this->assign('meta_title', '结算明细'); + $this->assign('meta_title', $metaTitle); + $this->assign('modelList', $modelList); + $this->display(); + } + + //提现 + public function withdraw() + { + //是否是会长 + $this->purview(); + //验证安全密码 + $metaTitle = '结算明细'; + $modelList = ['财务管理', $metaTitle]; + $res = $this->verifyPasswordView($modelList, false); + if ($res == false) { + $data['status'] = 0; + $data['msg'] = '权限异常'; + $this->ajaxReturn($data); + } + + $spendModel = M('spend', 'tab_'); + $thisDay = strtotime(date('Y-m-d')); + + $map['chain'] = ['like', $this->loginPromote['chain'] . $this->loginPromote['id'] . '/%']; + $promoteIds = M('promote', 'tab_')->where($map)->getField('id', true); + $promoteIds[] = $this->loginPromote['id']; + $promoteIds = implode(',', $promoteIds); + + $map = []; + $map['pay_status'] = 1; + $map['selle_status'] = 0; + $map['promote_id'] = ['in', $promoteIds]; + $map['pay_time'] = ['lt', $thisDay]; + $balance = $spendModel->field("sum(pay_amount * selle_ratio) as balance") + ->where($map) + ->find()['balance']; + $balance = bcdiv($balance, 100, 2); + if ($balance < 100) { + $data['status'] = 0; + $data['msg'] = '账户余额低于100元,无法提现!'; + $this->ajaxReturn($data); + } + $spendIds = $spendModel->where($map)->getField('id', true); + if (!empty($spendIds)) { + $data['status'] = 0; + $data['msg'] = '数据异常'; + $this->ajaxReturn($data); + } + + $thisTime = time(); + $add['sum_money'] = $balance; + $add['promote_id'] = $this->loginPromote['id']; + $add['promote_account'] = $this->loginPromote['account']; + $add['create_time'] = $thisTime; + $add['status'] = 0; + $add['widthdraw_number'] = $this->produceWithdrawNumber(); + $add['settlement_end_time'] = $thisDay - 1; + + M()->startTrans();//开启事物 + $withdrawId = M('withdraw', 'tab_')->add($add); + if (!$withdrawId) { + M()->rollback();//事物回滚 + $data['status'] = 0; + $data['msg'] = '提现失败'; + $this->ajaxReturn($data); + } + + $map = []; + $map['id'] = ['in', $spendIds]; + $save['selle_status'] = 1; + $save['selle_time'] = $thisTime; + $save['withdraw_id'] = $withdrawId; + $res = $spendModel->where($map)->save($save); + if ($res === false) { + M('withdraw', 'tab_')->delete($withdrawId); + M()->rollback();//事物回滚 + $data['status'] = 0; + $data['msg'] = '提现失败'; + $this->ajaxReturn($data); + } + + M()->commit();//事物提交 + $data['status'] = 1; + $data['msg'] = '提现成功'; + $this->ajaxReturn($data); + } + + //提现记录 + public function withdrawRecord() + { + //是否是会长 + $this->purview(); + //验证安全密码 + $metaTitle = '提现记录'; + $modelList = ['财务管理', $metaTitle]; + $this->verifyPasswordView($modelList); + + $model = M('withdraw', 'tab_'); + $page = intval(I('get.p', 1)); + $page = $page ? $page : 1; //默认显示第一页数据arraypage + $row = intval(I('get.row', 10)); + $withdrawNumber = I('widthdraw_number', ''); + $initBegTime = I('begtime', ''); + $initEndTime = I('endtime', ''); + $begTime = strtotime(date('Y-m-d', strtotime($initBegTime))); + $endTime = strtotime(date('Y-m-d', strtotime($initEndTime))) + 3600 * 24; + $status = ''; + + $parameter['p'] = $page; + $parameter['row'] = $row; + $parameter['widthdraw_number'] = $withdrawNumber; + $parameter['begtime'] = $initBegTime; + $parameter['endtime'] = $initEndTime; + + $map['promote_id'] = $this->loginPromote['id']; + if (!empty($withdrawNumber)) { + $map['widthdraw_number'] = $withdrawNumber; + } + if (!empty($initBegTime) && empty($initEndTime)) { + $map['create_time'] = ['egt', $begTime]; + } elseif (empty($initBegTime) && !empty($initEndTime)) { + $map['create_time'] = ['lt', $endTime]; + } elseif (!empty($initBegTime) && !empty($initEndTime)) { + $map['create_time'] = ['between', [$begTime, $endTime - 1]]; + } + if (isset($_GET['status']) && $_GET['status'] !== '') { + $status = intval($_GET['status']); + if (!isset(FinanceController::$withdrawStatus[$status])) { + if (!isset(FinanceController::$withdrawStatus[$status])) { + $this->error('参数异常'); + } + + $map['status'] = $status; + } + } + + $data = $model->field('id,widthdraw_number,create_time,settlement_end_time,sum_money,status,respond') + ->where($map) + ->order('id desc') + ->page($page, $row) + ->select(); + $count = $model + ->where($map) + ->count(); + + if (!empty($data)) { + foreach ($data as &$list) { + $list['create_time'] = date('Y-m-d H:i:s', $list['create_time']); + $list['settlement_end_time'] = date('Y-m-d H:i:s', $list['settlement_end_time']); + $list['status'] = FinanceController::$withdrawStatus[$list['status']]; + } + } + + $page = set_pagination($count, $row, $parameter); + + $this->assign('listData', $data); + $this->assign('count', $count); + $this->assign('initBegTime', $initBegTime); + $this->assign('initEndTime', $initEndTime); + $this->assign('status', $status); + $this->assign('_page', $page); + $this->assign('meta_title', $metaTitle); + $this->assign('modelList', $modelList); + $this->display(); + } + + //提现明细 + public function withdrawDtl() + { + //是否是会长 + $this->purview(); + //验证安全密码 + $metaTitle = '提现明细'; + $modelList = ['财务管理', '提现记录', $metaTitle]; + $this->verifyPasswordView($modelList); + + $model = M('withdraw', 'tab_'); + $spendModel = M('spend', 'tab_'); + $page = intval(I('get.p', 1)); + $page = $page ? $page : 1; //默认显示第一页数据arraypage + $row = intval(I('get.row', 10)); + $withdrawId = intval(I('get.id', 0)); + if ($withdrawId == 0) { + $this->error('参数异常'); + } + $withdraw = $model->field('promote_id,status')->where(array('id' => $withdrawId))->find(); + if (empty($withdraw) || $withdraw['promote_id'] != $this->loginPromote['id']) { + $this->error('参数异常'); + } + $gameId = intval(I('game_id', 0)); + $userAccount = I('user_account', ''); + $payOrderNumber = I('pay_order_number', ''); + + $parameter['p'] = $page; + $parameter['row'] = $row; + $parameter['id'] = $withdrawId; + $parameter['game_id'] = $gameId; + $parameter['user_account'] = $userAccount; + $parameter['pay_order_number'] = $payOrderNumber; + + $map['withdraw_id'] = $withdrawId; + if (!empty($gameId)) { + $map['game_id'] = $gameId; + } + if (!empty($userAccount)) { + $map['user_account'] = $userAccount; + } + if (!empty($payOrderNumber)) { + $map['pay_order_number'] = $payOrderNumber; + } + + $data = $spendModel + ->field('id,pay_order_number,game_name,sdk_version,user_account,pay_amount,pay_way,selle_ratio,pay_time') + ->where($map) + ->order('id desc') + ->page($page, $row) + ->select(); + $count = $spendModel + ->where($map) + ->count(); + + if (!empty($data)) { + foreach ($data as &$list) { + $list['income'] = bcmul($list['pay_amount'], bcdiv($list['selle_ratio'], 100, 2), 2); + $list['pay_time'] = date('Y-m-d H:i:s', $list['pay_time']); + switch ($list['pay_way']) { + case 2: + case 3: + case 4: + $list['pay_way_name'] = QueryController::$payWay[2]; + break; + default: + $list['pay_way_name'] = QueryController::$payWay[$list['pay_way']]; + break; + } + } + } + + $page = set_pagination($count, $row, $parameter); + + $this->assign('listData', $data); + $this->assign('count', $count); + $this->assign('status', FinanceController::$withdrawStatus[$withdraw['status']]); + $this->assign('_page', $page); + $this->assign('meta_title', $metaTitle); + $this->assign('modelList', $modelList); $this->display(); } } \ No newline at end of file diff --git a/Application/Home/Controller/GameDivideController.class.php b/Application/Home/Controller/GameDivideController.class.php index 530d90632..84114dc66 100644 --- a/Application/Home/Controller/GameDivideController.class.php +++ b/Application/Home/Controller/GameDivideController.class.php @@ -22,7 +22,7 @@ class GameDivideController extends BaseController //验证安全密码 $metaTitle = '分成比例'; $modelList = ['游戏管理', $metaTitle]; - $this->verifyPasswordView($modelList, $metaTitle); + $this->verifyPasswordView($modelList); $map['tab_game.online_status'] = 1;//开发者游戏上线状态 $map['tab_game.down_port'] = 1;//游戏端口 第三方接口不能申请 @@ -78,6 +78,7 @@ class GameDivideController extends BaseController $this->assign('count', $count); $this->assign('serverType', I('server_type', 0)); $this->meta_title = $metaTitle; + $this->assign('modelList', $modelList); $this->display(); } } \ No newline at end of file diff --git a/Application/Home/Controller/PromoteController.class.php b/Application/Home/Controller/PromoteController.class.php index e9c833910..159239644 100644 --- a/Application/Home/Controller/PromoteController.class.php +++ b/Application/Home/Controller/PromoteController.class.php @@ -66,14 +66,14 @@ class PromoteController extends BaseController $promote_id = get_pid(); $field = 'id,game_name,server_name,user_account,nickname,promote_account,detail,create_time as update_time'; - $rz_list = M("protect_log","tab_")->field($field)->where("promote_id = {$promote_id}")->limit('0,5')->order("create_time desc")->select(); //日志管理 + $rz_list = M("protect_log", "tab_")->field($field)->where("promote_id = {$promote_id}")->limit('0,5')->order("create_time desc")->select(); //日志管理 - $logCount = M('protect_log','tab_')->where("promote_id = {$promote_id}")->count(); - $readLogCount = M('protect_log_read','tab_')->where("promote_id = {$promote_id}")->count(); + $logCount = M('protect_log', 'tab_')->where("promote_id = {$promote_id}")->count(); + $readLogCount = M('protect_log_read', 'tab_')->where("promote_id = {$promote_id}")->count(); $gg_data = M("document", "sys_")->where("category_id=56 and status=1")->order("update_time desc")->select(); $gg_Count = count($gg_data); - $gg_data = implode(',',array_column($gg_data,'id')); + $gg_data = implode(',', array_column($gg_data, 'id')); $gg_where = "promote_id = {$promote_id} and category_id=56"; if ($gg_data) { @@ -85,7 +85,7 @@ class PromoteController extends BaseController $zx_data = M("document", "sys_")->where("category_id=51 and status=1")->order("update_time desc")->select(); $zx_Count = count($zx_data); - $zx_data = implode(',',array_column($zx_data,'id')); + $zx_data = implode(',', array_column($zx_data, 'id')); $zx_where = "promote_id = {$promote_id} and category_id=51"; if ($zx_data) { $zx_where .= " and document_id IN({$zx_data})"; @@ -97,8 +97,8 @@ class PromoteController extends BaseController $today_end = mktime(0, 0, 0, date('m'), date('d') + 1, date('Y')) - 1; $today_open_server_list = M("server as sv", "tab_") ->where( - array("sv.start_time" => array("BETWEEN", array($today_start, $today_end)), - "sv.show_status" => 1)) + array("sv.start_time" => array("BETWEEN", array($today_start, $today_end)), + "sv.show_status" => 1)) ->join("left join tab_game gm on gm.id=sv.game_id") ->field('sv.*,gm.icon') ->order("sv.start_time desc") @@ -122,29 +122,29 @@ class PromoteController extends BaseController //计算当日用户充值数据 $map['_string'] = "promote_id = {$promote_id} or tab_promote.parent_id = {$promote_id} or tab_promote.chain like '%/{$promote_id}/%' "; - $pay_time = " between 0 and ".time(); - $spendData = $this->caculateSpend($pay_time,$map['_string']); + $pay_time = " between 0 and " . time(); + $spendData = $this->caculateSpend($pay_time, $map['_string']); - $promoteId = implode(',',$promoteId); + $promoteId = implode(',', $promoteId); if ($promoteId) { $user_count = M("user", "tab_")->where("promote_id IN({$promoteId})")->count(); } else { $user_count = 0; } - $today=total(1); + $today = total(1); $yesterdays = total(5); - $week=total(2); - $mounth=total(3); + $week = total(2); + $mounth = total(3); //计算今日的统计数据 - $data=M('User','tab_') + $data = M('User', 'tab_') ->field('promote_account,promote_id,date_format(FROM_UNIXTIME(register_time),"%Y-%m-%d") AS time, count(tab_user.id) as count, IF(tab_promote.grand_id>0,tab_promote.grand_id,IF(tab_promote.grand_id=0 and tab_promote.parent_id >0,tab_promote.parent_id,promote_id)) as promote_id1 , - count(IF(register_time '.$yesterdays.',1,null)) as yesterday, - 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 on promote_id = tab_promote.id','left') + count(IF(register_time ' . $yesterdays . ',1,null)) as yesterday, + 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 on promote_id = tab_promote.id', 'left') ->where($map) ->group('promote_id1') ->having('promote_id != 0') @@ -152,42 +152,42 @@ class PromoteController extends BaseController ->find(); // echo M('User','tab_')->_sql();die(); - $total_money = $this->pay_total(0, 0,$promoteId); - $today_add_user_money = $this->pay_total(1,1,$promoteId); - $month_add_user_money = $this->pay_total(3,1,$promoteId); + $total_money = $this->pay_total(0, 0, $promoteId); + $today_add_user_money = $this->pay_total(1, 1, $promoteId); + $month_add_user_money = $this->pay_total(3, 1, $promoteId); $yesterday_start = mktime(0, 0, 0, date('m'), date('d') - 1, date('Y')); $yesterday_end = mktime(0, 0, 0, date('m'), date('d'), date('Y')); //计算昨天用户的统计数据,当日用户充值数据 $pay_time = " between {$yesterday_start} and {$yesterday_end}"; - $createTime = ['between',array($yesterday_start,$yesterday_end-1)]; - $yesterdaySpendData = $this->caculateSpend($pay_time,$map['_string'],$createTime); + $createTime = ['between', array($yesterday_start, $yesterday_end - 1)]; + $yesterdaySpendData = $this->caculateSpend($pay_time, $map['_string'], $createTime); - $todayAddSpendData = $this->caculateSpend($pay_time,$map['_string'],[],1); + $todayAddSpendData = $this->caculateSpend($pay_time, $map['_string'], [], 1); - $mounthAddSpendData = $this->caculateSpend($pay_time,$map['_string'],[],2); + $mounthAddSpendData = $this->caculateSpend($pay_time, $map['_string'], [], 2); $yesterday_user_regist_count = M("user", "tab_")->where( - array("promote_id" => array('in',$promoteId), + array("promote_id" => array('in', $promoteId), "register_time" => array("BETWEEN", array($yesterday_start, $yesterday_end)))) ->count(); - $yesterday_total_money = $this->pay_total(5, 0,$promoteId); + $yesterday_total_money = $this->pay_total(5, 0, $promoteId); $today_start = mktime(0, 0, 0, date('m'), date('d'), date('Y')); $today_end = mktime(0, 0, 0, date('m'), date('d') + 1, date('Y')) - 1; $today_regist_user_count = M("user", "tab_") - ->where(array("promote_id" => array('in',$promoteId), + ->where(array("promote_id" => array('in', $promoteId), "register_time" => array("BETWEEN", array($today_start, $today_end)))) ->count(); - $today_total_money = $this->pay_total(1, 0,$promoteId); + $today_total_money = $this->pay_total(1, 0, $promoteId); - $this->assign('data',$data); + $this->assign('data', $data); // $this->assign('yesterdayData',$yesterdayData); - $this->assign('spendData',$spendData); - $this->assign('yesterdaySpendData',$yesterdaySpendData); - $this->assign('todayAddSpendData',$todayAddSpendData); - $this->assign('mounthAddSpendData',$mounthAddSpendData); + $this->assign('spendData', $spendData); + $this->assign('yesterdaySpendData', $yesterdaySpendData); + $this->assign('todayAddSpendData', $todayAddSpendData); + $this->assign('mounthAddSpendData', $mounthAddSpendData); $this->assign("user_count", $user_count); @@ -202,106 +202,107 @@ class PromoteController extends BaseController $this->assign("menu_list", $quick_menu_list); $this->assign("gg_list", $gg_list); - $this->assign("gg_count", $gg_Count-$gg_ReadDocument); + $this->assign("gg_count", $gg_Count - $gg_ReadDocument); $this->assign("zx_list", $zx_list); - $this->assign("zx_count", $zx_Count-$zx_ReadDocument); + $this->assign("zx_count", $zx_Count - $zx_ReadDocument); $this->assign("xx_list", $xx_list); $this->assign('rz_list', $rz_list); - $this->assign("rz_count", $logCount-$readLogCount); + $this->assign("rz_count", $logCount - $readLogCount); $this->assign("today_open_server_list", $today_open_server_list); $this->assign("game_list", $game_list); $this->meta_title = "首页"; $this->display(); } - private function caculateSpend($pay_time,$condition,$create = [],$type = 0) { - $spend=M('Spend','tab_'); - $today=total(1); - $week=total(2); - $mounth=total(3); - - $map1['promote_id'] = $map['promote_id']=array('gt',0); - $map1['pay_status'] = $map['pay_status']=1; - $map1['pay_way'] = $map['pay_way'] = array('gt',0); + private function caculateSpend($pay_time, $condition, $create = [], $type = 0) + { + $spend = M('Spend', 'tab_'); + $today = total(1); + $week = total(2); + $mounth = total(3); + + $map1['promote_id'] = $map['promote_id'] = array('gt', 0); + $map1['pay_status'] = $map['pay_status'] = 1; + $map1['pay_way'] = $map['pay_way'] = array('gt', 0); $userId = []; - $promoteId = M("promote", "tab_")->field('id')->where("parent_id=" . get_pid()." or grand_id=". get_pid())->select(); - $promoteId = array_column($promoteId,'id'); - $promoteId = implode(',',$promoteId).",".get_pid(); - $whereUser['promote_id'] = ['IN',$promoteId]; + $promoteId = M("promote", "tab_")->field('id')->where("parent_id=" . get_pid() . " or grand_id=" . get_pid())->select(); + $promoteId = array_column($promoteId, 'id'); + $promoteId = implode(',', $promoteId) . "," . get_pid(); + $whereUser['promote_id'] = ['IN', $promoteId]; if ($type == 1) { $start = mktime(0, 0, 0, date('m'), date('d'), date('Y')); $end = mktime(0, 0, 0, date('m'), date('d') + 1, date('Y')) - 1; - $whereUser['register_time'] = ['between',array($start,$end-1)]; - $userId = M('user','tab_')->field('id')->where($whereUser)->select(); + $whereUser['register_time'] = ['between', array($start, $end - 1)]; + $userId = M('user', 'tab_')->field('id')->where($whereUser)->select(); } else if ($type == 2) { $start = mktime(0, 0, 0, date('m'), 1, date('Y')); $end = mktime(0, 0, 0, date('m') + 1, 1, date('Y')) - 1; - $whereUser['register_time'] = ['between',array($start,$end-1)]; - $userId = M('user','tab_')->field('id')->where($whereUser)->select(); + $whereUser['register_time'] = ['between', array($start, $end - 1)]; + $userId = M('user', 'tab_')->field('id')->where($whereUser)->select(); } - $userId = implode(',',array_column($userId,'id')); + $userId = implode(',', array_column($userId, 'id')); if ($userId) { - $map1['user_id'] = $map['user_id']=['IN',$userId]; - } else if (!$userId&&$type!=0) { - return array('today'=>0,'mounth'=>0); + $map1['user_id'] = $map['user_id'] = ['IN', $userId]; + } else if (!$userId && $type != 0) { + return array('today' => 0, 'mounth' => 0); } if ($create) { $map['create_time'] = $create; } - $bindrecharge_data = M('bind_recharge','tab_') + $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') + 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_') + $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') + 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') // ->join('tab_user on tab_user.id = tab_spend.user_id','left') ->where($map1) ->group('promote_id') ->select(false); - $spendData=$spend + $spendData = $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') + 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') // ->join('tab_user on tab_user.id = tab_spend.user_id','left') ->where($map) - ->union(' ('.$bindrecharge_data.') ') - ->union(' ('.$deposit_data.') ') + ->union(' (' . $bindrecharge_data . ') ') + ->union(' (' . $deposit_data . ') ') ->group('promote_id') ->select(false); $spendData = $spend->field('a.promote_account,a.promote_id,a.time,sum(a.scount) as count,sum(a.today) as today,sum(a.week) as week,sum(a.mounth) as mounth,IF(tab_promote.grand_id>0,tab_promote.grand_id,IF(tab_promote.grand_id=0 and tab_promote.parent_id >0,tab_promote.parent_id,promote_id)) as promote_id1') - ->join('tab_promote on promote_id = tab_promote.id','left') + ->join('tab_promote on promote_id = tab_promote.id', 'left') ->where($condition) - ->table('('.$spendData.') as a')->group('promote_id1')->order('count desc,a.ordertime')->find(); - $spendData['rand']=1; - $spendData['count']=$spendData['count']/100; - $spendData['today']=$spendData['today']/100; - $spendData['week']=$spendData['week']/100; - $spendData['mounth']=$spendData['mounth']/100; + ->table('(' . $spendData . ') as a')->group('promote_id1')->order('count desc,a.ordertime')->find(); + $spendData['rand'] = 1; + $spendData['count'] = $spendData['count'] / 100; + $spendData['today'] = $spendData['today'] / 100; + $spendData['week'] = $spendData['week'] / 100; + $spendData['mounth'] = $spendData['mounth'] / 100; return $spendData; } - private function pay_total($type = 0, $newadd = 1,$promoteId="") + private function pay_total($type = 0, $newadd = 1, $promoteId = "") { if ($_REQUEST['promote_id'] === null || $_REQUEST['promote_id'] === '0') { $map['parent_id'] = get_pid(); @@ -482,7 +483,7 @@ class PromoteController extends BaseController } else { $menuData = M("promote_quick_menu ", "tab_")->where(array("promote_id" => get_pid()))->count(); - if ($menuData>=10) { + if ($menuData >= 10) { $this->ajaxReturn(['status' => 1, 'info' => '快捷菜单只能有10个'], "JSON"); } M("promote_quick_menu ", "tab_")->add( @@ -524,12 +525,12 @@ class PromoteController extends BaseController $count = M("document", "sys_")->where("category_id=56 and status=1")->count(); } $promote_id = get_pid(); - $logCount = M('protect_log','tab_')->count(); - $readLogCount = M('protect_log_read','tab_')->where("promote_id = {$promote_id}")->count(); + $logCount = M('protect_log', 'tab_')->count(); + $readLogCount = M('protect_log_read', 'tab_')->where("promote_id = {$promote_id}")->count(); $gg_data = M("document", "sys_")->where("category_id=56 and status=1")->order("update_time desc")->select(); $gg_Count = count($gg_data); - $gg_data = implode(',',array_column($gg_data,'id')); + $gg_data = implode(',', array_column($gg_data, 'id')); $gg_where = "promote_id = {$promote_id} and category_id=56"; if ($gg_data) { @@ -541,7 +542,7 @@ class PromoteController extends BaseController $zx_data = M("document", "sys_")->where("category_id=51 and status=1")->order("update_time desc")->select(); $zx_Count = count($zx_data); - $zx_data = implode(',',array_column($zx_data,'id')); + $zx_data = implode(',', array_column($zx_data, 'id')); $zx_where = "promote_id = {$promote_id} and category_id=51"; if ($zx_data) { $zx_where .= " and document_id IN({$zx_data})"; @@ -558,9 +559,9 @@ class PromoteController extends BaseController $this->meta_title = "公告列表"; $this->assign("type", $type); $this->assign("data_list", $data_list); - $this->assign("gg_count", $gg_Count-$gg_ReadDocument); - $this->assign("zx_count", $zx_Count-$zx_ReadDocument); - $this->assign("rz_count", $logCount-$readLogCount); + $this->assign("gg_count", $gg_Count - $gg_ReadDocument); + $this->assign("zx_count", $zx_Count - $zx_ReadDocument); + $this->assign("rz_count", $logCount - $readLogCount); $this->display(); } @@ -837,7 +838,7 @@ class PromoteController extends BaseController $map = []; $map['chain'] = ['like', $loginer['chain'] . $loginer['id'] . '/%']; - + if ($promoteType == 0) { $map['level'] = 2; } elseif ($promoteType == 1) { @@ -863,7 +864,7 @@ class PromoteController extends BaseController } $query = M('promote', 'tab_')->where($map); list($records, $pagination, $count) = $this->paginate($query); - + $ids = array_column($records, 'id'); $countList = []; @@ -917,7 +918,7 @@ class PromoteController extends BaseController } $status = $promoteService->addPromote($params, $parent); if ($status) { - $this->ajaxReturn(['status' => 1, 'msg' => '添加成功']); + $this->ajaxReturn(['status' => 1, 'msg' => '添加成功']); } else { $this->ajaxReturn(['status' => 0, 'msg' => '添加失败']); } @@ -926,7 +927,7 @@ class PromoteController extends BaseController $loginer = $this->getLoginPromote(); $promotes = null; $promoteColumns = ['id', 'account', 'real_name']; - $promoteMap = ['chain' => ['like', $loginer['chain'] . $loginer['id'] . '/' . '%']]; + $promoteMap = ['chain' => ['like', $loginer['chain'] . $loginer['id'] . '/' . '%']]; if ($loginer['level'] == 1) { if ($promoteType == 1) { $promoteMap['level'] = 2; @@ -1857,9 +1858,15 @@ class PromoteController extends BaseController //验证安全密码 $metaTitle = '设置'; $modelList = ['游戏管理', $metaTitle]; - $this->verifyPasswordView($modelList, $metaTitle); + $res = $this->verifyPasswordView($modelList, ($_POST ? false : true)); if ($_POST) { + if ($res === false) { + $data['status'] = 0; + $data['msg'] = '权限异常'; + $this->ajaxReturn($data); + } + $save['child_game_permission'] = I('post.child_game_permission'); $saveRes = D('Promote')->where(array('id' => PID))->save($save); if ($saveRes === false) { @@ -1877,6 +1884,7 @@ class PromoteController extends BaseController $this->assign('data', $promoteData); $this->meta_title = $metaTitle; + $this->assign('modelList', $modelList); $this->display(); } } diff --git a/Application/Home/View/default/Finance/index.html b/Application/Home/View/default/Finance/index.html new file mode 100644 index 000000000..c527c2559 --- /dev/null +++ b/Application/Home/View/default/Finance/index.html @@ -0,0 +1,184 @@ + + + + + + +
+
    +
  • 历史收益

    ¥{$income.history_income}
  • +
  • 本月收益

    ¥{$income.this_month_income}
  • +
  • 昨日收益

    ¥{$income.yesterday_income}
  • +
  • 账户余额

    ¥{$income.balance}
  • +
+
+
+ +
+
+
{$meta_title}
+
+ +
+ + + + + + + + + + + + + + + + + +
时间收益操作

暂无数据

{$data.day}{$data.income}明细
+
+
+ {$_page} +
+
+
+ + + + + + + +
\ No newline at end of file diff --git a/Application/Home/View/default/Finance/settlementDtl.html b/Application/Home/View/default/Finance/settlementDtl.html index f66bf47b3..08d2c16fa 100644 --- a/Application/Home/View/default/Finance/settlementDtl.html +++ b/Application/Home/View/default/Finance/settlementDtl.html @@ -66,7 +66,15 @@
diff --git a/Data/update.sql b/Data/update.sql index ebabebfe9..ffb537dea 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -336,3 +336,6 @@ CREATE TABLE `tab_spend_user_count` ( KEY `count_date` (`count_date`) USING BTREE ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='流水角色聚合表'; +-- 2019-11-6 cxj +ALTER TABLE `tab_spend` ADD COLUMN `withdraw_id` int(11) NOT NULL DEFAULT 0 COMMENT '提现ID' AFTER `pay_url`; +ALTER TABLE `tab_withdraw` ADD COLUMN `settlement_end_time` int(10) NOT NULL DEFAULT 0 COMMENT '结算截止时间' AFTER `old_promote_account`; \ No newline at end of file From f4702e365bb8d65164abe2458af07c6f26924150 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9C=E7=94=A8lww?= <“529520975@qq.com> Date: Thu, 7 Nov 2019 09:42:57 +0800 Subject: [PATCH 2/2] =?UTF-8?q?composer=E5=8C=85=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E5=9B=BD=E5=86=85=E9=95=9C=E5=83=8F=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/composer.json b/composer.json index 069baf26b..75f9c6467 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,11 @@ { "require": { "rodneyrehm/plist": "^2.0" + }, + "repositories": { + "packagist": { + "type": "composer", + "url": "https://packagist.phpcomposer.com" + } } }