diff --git a/Application/Base/Repository/PromoteRepository.class.php b/Application/Base/Repository/PromoteRepository.class.php index 253b2b392..4ad190ed0 100644 --- a/Application/Base/Repository/PromoteRepository.class.php +++ b/Application/Base/Repository/PromoteRepository.class.php @@ -20,7 +20,7 @@ class PromoteRepository { /** * 获取业绩公共map */ - private function getPublicAchievementMap($ids, $params) + private function getPublicAchievementMap($ids, $params, $type = null) { $isContainSubs = false; if (isset($params['isContainSubs']) && $params['isContainSubs']) { @@ -51,6 +51,10 @@ class PromoteRepository { if (isset($params['begin_time']) && isset($params['end_time']) && isset($params['time_column'])) { $map[$params['time_column']] = ['between', [$params['begin_time'], $params['end_time']]]; } + if ($type == 'spend') { + $spendRepository = new SpendRepository(); + $map = $spendRepository->withIsCheck($map); + } if (isset($params['lock_status'])) { $lockUserIds = M('user', 'tab_')->where(['lock_status' => 0, 'promote_id' => ['in', $allIds]])->getField('id', 'true'); if (count($lockUserIds) > 0) { @@ -308,7 +312,7 @@ class PromoteRepository { } $params['time_column'] = 'pay_time'; - $map = $this->getPublicAchievementMap($ids, $params); + $map = $this->getPublicAchievementMap($ids, $params, 'spend'); $items = M('spend', 'tab_')->field(['count(*) count', 'promote_id'])->where($map)->group('promote_id')->select(); @@ -340,7 +344,7 @@ class PromoteRepository { } $params['time_column'] = 'pay_time'; - $map = $this->getPublicAchievementMap($ids, $params); + $map = $this->getPublicAchievementMap($ids, $params, 'spend'); $items = M('spend', 'tab_')->field(['count(distinct user_id) count', 'promote_id'])->where($map)->group('promote_id')->select(); $records = []; @@ -371,7 +375,7 @@ class PromoteRepository { } $params['time_column'] = 'pay_time'; - $map = $this->getPublicAchievementMap($ids, $params); + $map = $this->getPublicAchievementMap($ids, $params, 'spend'); $map['pay_status'] = 1; $items = M('spend', 'tab_')->field(['sum(pay_amount) amount', 'promote_id', 'pay_way'])->where($map)->group('promote_id, pay_way')->select(); // echo M()->getLastSql();die(); diff --git a/Application/Base/Repository/SpendRepository.class.php b/Application/Base/Repository/SpendRepository.class.php index b9b483087..1421a45e7 100644 --- a/Application/Base/Repository/SpendRepository.class.php +++ b/Application/Base/Repository/SpendRepository.class.php @@ -43,6 +43,8 @@ class SpendRepository $conditions['pay_status'] = 1; $conditions['pay_time'] = ['between', [$beginTime, $endTime]]; + $conditions = $this->withIsCheck($conditions); + return $conditions; } @@ -65,6 +67,8 @@ class SpendRepository } $conditions['pay_time'] = ['between', [$beginTime, $endTime]]; + $conditions = $this->withIsCheck($conditions); + return $conditions; } @@ -85,6 +89,9 @@ class SpendRepository if (isset($params['server_id'])) { $conditions['server_id'] = $serverId; } + + $conditions = $this->withIsCheck($conditions); + $conditions['pay_way'] = $isBan ? ['neq', '-10'] : ['neq', '-1']; return $conditions; } @@ -108,6 +115,9 @@ class SpendRepository if (isset($params['pay_way'])) { $conditions['pay_way'] = $params['pay_way']; } + + $conditions = $this->withIsCheck($conditions); + return $conditions; } @@ -370,8 +380,8 @@ class SpendRepository return $this->assembleRecords($items, $gameIds, 'count', 'game_id'); } - public function getCommonQuery($params, $columns = '*') + public function withIsCheck($map, $column = 'is_check') { - // return M('spend', 'tab_')->field($columns)->where($map); + return array_merge($map, [$column => 1]); } } \ No newline at end of file diff --git a/Application/Base/Repository/TestingResourceRepository.class.php b/Application/Base/Repository/TestingResourceRepository.class.php index ad62b42b0..5a0800a9d 100644 --- a/Application/Base/Repository/TestingResourceRepository.class.php +++ b/Application/Base/Repository/TestingResourceRepository.class.php @@ -290,6 +290,7 @@ class TestingResourceRepository } } + $spendItems = []; if (count($bindingRoles) > 0) { $spendOrWhere = []; @@ -300,13 +301,18 @@ class TestingResourceRepository 'pay_status' => 1, '_string' => '(' . implode(' or ', $spendOrWhere) . ')', ]; + $subBindingCondition = [ + '_string' => + 'tab_testing_binding.bind_role_id = tab_spend.game_player_id and ' . + 'tab_testing_binding.game_id = tab_spend.game_id and ' . + 'UNIX_TIMESTAMP(FROM_UNIXTIME(tab_testing_binding.create_time, "%Y-%m-%d 00:00:00")) <= tab_spend.pay_time' + ]; + $spendRepository = new SpendRepository(); + $subBindingCondition = $spendRepository->withIsCheck($subBindingCondition, 'tab_spend.is_check'); + $spendCondition = $spendRepository->withIsCheck($spendCondition); + $subBindingSql = M('testing_binding', 'tab_') - ->where([ - '_string' => - 'tab_testing_binding.bind_role_id = tab_spend.game_player_id and ' . - 'tab_testing_binding.game_id = tab_spend.game_id and ' . - 'UNIX_TIMESTAMP(FROM_UNIXTIME(tab_testing_binding.create_time, "%Y-%m-%d 00:00:00")) <= tab_spend.pay_time' - ]) + ->where($subBindingCondition) ->select(false); $spendCondition['_string'] .= ' and exists(' . $subBindingSql . ')'; $spendList = M('spend', 'tab_') diff --git a/Application/Base/Service/PromoteGradeService.class.php b/Application/Base/Service/PromoteGradeService.class.php index 8e644d771..fd9d42512 100644 --- a/Application/Base/Service/PromoteGradeService.class.php +++ b/Application/Base/Service/PromoteGradeService.class.php @@ -2,6 +2,7 @@ namespace Base\Service; use Base\Facade\Request; +use Base\Repository\SpendRepository; class PromoteGradeService { @@ -153,12 +154,15 @@ class PromoteGradeService '_string' => 'user_id in (' . $userSubSql . ')' ]; + $spendRepository = new SpendRepository(); + $spendMap = [ 'pay_time' => ['between', $betweenTime], 'pay_status' => 1, 'promote_id' => ['in', $promoteIds], '_string' => 'user_id in (' . $userSubSql . ')' ]; + $spendMap = $spendRepository->withIsCheck($spendMap); if ($baseGame) { $roleMap['game_id'] = ['in', [$baseGame['android_game_id'], $baseGame['ios_game_id']]]; diff --git a/Application/Base/Service/PromoteService.class.php b/Application/Base/Service/PromoteService.class.php index 0d2cbb3a2..86236bc4e 100644 --- a/Application/Base/Service/PromoteService.class.php +++ b/Application/Base/Service/PromoteService.class.php @@ -338,7 +338,7 @@ class PromoteService { $users = M('user', 'tab_')->field(['id', 'account', 'nickname'])->where($map)->select(); $spendMap['pay_time'] = ['egt', $orderTime]; - $spendMap['is_check'] = ['in','1,2']; + // $spendMap['is_check'] = ['in','1,2']; $spendMap['settle_check'] = 0; $spendMap['selle_status'] = 0; $spendMap['pay_status'] = 1; diff --git a/Application/Base/Service/TestingResourceService.class.php b/Application/Base/Service/TestingResourceService.class.php index 9d28e4856..74b4d04bb 100644 --- a/Application/Base/Service/TestingResourceService.class.php +++ b/Application/Base/Service/TestingResourceService.class.php @@ -4,6 +4,7 @@ namespace Base\Service; use Base\Facade\Request; use Base\Tool\GameResource; use Base\Repository\TestingResourceRepository; +use Base\Repository\SpendRepository; use Think\Model; class TestingResourceService @@ -154,13 +155,18 @@ class TestingResourceService $totalQuota = $role['testing_other_quota'] + ($gameSetting['base_quota'] ?? 0); if (!is_null($bindRole)) { $bindTime = $bindRole['binding_time'] ?? 0; + + $spendMap = [ + 'game_id' => $role['game_id'], + 'game_player_id' => $bindRole['role_id'], + 'pay_status' => 1, + 'pay_time' => ['egt', strtotime(date('Y-m-d 00:00:00', $bindTime))] + ]; + $spendRepository = new SpendRepository(); + $spendMap = $spendRepository->withIsCheck($spendMap); + $spendQuota += M('spend', 'tab_') - ->where([ - 'game_id' => $role['game_id'], - 'game_player_id' => $bindRole['role_id'], - 'pay_status' => 1, - 'pay_time' => ['egt', strtotime(date('Y-m-d 00:00:00', $bindTime))] - ]) + ->where($spendMap) ->group('game_id,game_player_id') ->sum('pay_amount'); $totalQuota += round($gameSetting['rate'] / 100 * $spendQuota, 2); diff --git a/Application/Home/Common/function.php b/Application/Home/Common/function.php index c985dbcfa..80832b474 100644 --- a/Application/Home/Common/function.php +++ b/Application/Home/Common/function.php @@ -1385,4 +1385,32 @@ function data2csv(&$data,$title,$fields){ ob_flush(); fclose($fp); //每生成一个文件关闭 die(); +} + +function is_active_menu(array $controllers, array $actions, \Closure $otherCondition = null) +{ + $controllerStatus = true; + $actionStatus = true; + $otherConditionStatus = true; + if ($controllers && !in_array(CONTROLLER_NAME, $controllers)) { + $controllerStatus = false; + } + if ($actions && !in_array(ACTION_NAME, $actions)) { + $actionStatus = false; + } + if ($otherCondition) { + $otherConditionStatus = $otherCondition(); + } + if ($controllerStatus && $actionStatus && $otherConditionStatus) { + return true; + } + return false; +} + +function is_active_class(array $controllers, array $actions, \Closure $otherCondition = null) +{ + if (is_active_menu($controllers, $actions, $otherCondition)) { + return 'active'; + } + return ''; } \ No newline at end of file diff --git a/Application/Home/Controller/DownloadController.class.php b/Application/Home/Controller/DownloadController.class.php index 3b7fde07e..dfc9cc83e 100644 --- a/Application/Home/Controller/DownloadController.class.php +++ b/Application/Home/Controller/DownloadController.class.php @@ -18,7 +18,8 @@ use GuzzleHttp\Client; /** * @author elf<360197197@qq.com> */ -class DownloadController extends BaseController { +class DownloadController extends BaseController +{ public $payWay = [ -1 => '绑币', 0 => '平台币', @@ -46,6 +47,14 @@ class DownloadController extends BaseController { 0 => '下单未支付', 1 => '充值成功', ]; + + public $spendRepository; + + protected function _initialize() + { + parent::_initialize(); + $this->spendRepository = new SpendRepository(); + } /** * excel @@ -1491,8 +1500,6 @@ class DownloadController extends BaseController { empty(I('game_player_name')) || $map['tab_spend.game_player_name'] = ['like', '%' . I('game_player_name') . '%']; empty(I('user_account')) || $map['tab_spend.user_account'] = ['like', '%' . I('user_account') . '%']; empty(I('pay_order_number')) || $map['tab_spend.pay_order_number'] = I('pay_order_number'); - // $map['tab_spend.pay_status'] = 1; - // $map['tab_spend.is_check'] = ['neq', 2]; if (isset($_REQUEST['pay_status']) && $_REQUEST['pay_status'] !== '') { $payStatus = intval(I('pay_status')); @@ -1500,9 +1507,12 @@ class DownloadController extends BaseController { $map['tab_spend.pay_status'] = $payStatus + 2; } } - $conditions = json_encode($map,TRUE); - $addtime = time(); - $data = [ + + $map = $this->spendRepository->withIsCheck($map, 'tab_spend.is_check'); + + $conditions = json_encode($map, true); + $addtime = time(); + $data = [ 'logid' => 'cz_'.time(), 'promote_id' => PID, 'type' => '/Home/Query/recharge', @@ -2234,6 +2244,8 @@ class DownloadController extends BaseController { } } + $spendMap = $this->spendRepository->withIsCheck($spendMap); + $spendSubSql = M('spend', 'tab_')->field(['game_id', 'server_id', 'sum(pay_amount) amount'])->where($spendMap)->group('game_id, server_id')->select(false); $roleSubSql = M('user_play_info', 'tab_')->field(['game_id', 'server_id', 'count(*) count'])->where($roleMap)->group('game_id, server_id')->select(false); @@ -4476,6 +4488,9 @@ public function iosDetailExcelInfo($id,$map) { $spendMap['today.pay_status'] = 1; $spendMap['today.pay_time'] = ['between', [$now, $nowTimeEnd]]; + $map = $this->spendRepository->withIsCheck($map, 'uc.is_check'); + $spendMap = $this->spendRepository->withIsCheck($spendMap, 'today.is_check'); + $fieldToday = M('spend', 'tab_')->alias('today') ->field('sum(pay_amount) as recharge_cost_today') ->where($spendMap) diff --git a/Application/Home/Controller/FinanceController.class.php b/Application/Home/Controller/FinanceController.class.php index d65b914f6..17e287575 100644 --- a/Application/Home/Controller/FinanceController.class.php +++ b/Application/Home/Controller/FinanceController.class.php @@ -24,6 +24,14 @@ class FinanceController extends BaseController 2 => '已汇款', ]; + public $spendRepository; + + protected function _initialize() + { + parent::_initialize(); + $this->spendRepository = new SpendRepository(); + } + //权限过滤 private function purview() { @@ -127,6 +135,7 @@ class FinanceController extends BaseController $map = []; $map['pay_status'] = 1; $map['promote_id'] = ['in', $promoteIds]; + $map = $this->spendRepository->withIsCheck($map); $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, @@ -215,6 +224,7 @@ class FinanceController extends BaseController } else { $map['pay_status'] = 1; $map['selle_status'] = 0; + $map = $this->spendRepository->withIsCheck($map); $balance = M('spend', 'tab_')->field('sum(pay_amount * selle_ratio) as balance')->where($map)->find()['balance']; $balance = $balance ? bcdiv($balance , 100, 2) : 0; $settlementType = 3; @@ -290,7 +300,7 @@ class FinanceController extends BaseController private function getSumMoney($map = []) { $map['pay_status'] = 1; - + $map = $this->spendRepository->withIsCheck($map); $sumAmount = M('spend', 'tab_')->field('sum(pay_amount) as sum_amount')->where($map)->find()['sum_amount']; $sumAmount = $sumAmount ?? 0; return $sumAmount; @@ -396,7 +406,7 @@ class FinanceController extends BaseController } } } - + $map = $this->spendRepository->withIsCheck($map); $data = $model->field('pay_order_number,game_name,user_account,promote_id,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') @@ -505,6 +515,9 @@ class FinanceController extends BaseController $map['selle_status'] = 0; $map['promote_id'] = ['in', $promoteIds]; $map['pay_time'] = ['lt', $thisDay]; + + $map = $this->spendRepository->withIsCheck($map); + $balance = $spendModel->field("sum(pay_amount * selle_ratio) as balance") ->where($map) ->find()['balance']; @@ -742,6 +755,8 @@ class FinanceController extends BaseController $map['pay_order_number'] = $payOrderNumber; } + $map = $this->spendRepository->withIsCheck($map); + $data = $spendModel ->field('id,pay_order_number,game_name,sdk_version,user_account,pay_amount,pay_way,selle_ratio,pay_time') ->where($map) @@ -896,6 +911,9 @@ class FinanceController extends BaseController $this->ajaxReturn($data); } + $spendMap = []; + $spendMap = $this->spendRepository->withIsCheck($spendMap); + $spendMap['withdraw_id'] = $id; $spendIds = M('Spend', 'tab_')->where($spendMap)->getField('id', true); if (empty($spendIds)) { diff --git a/Application/Home/Controller/PromoteController.class.php b/Application/Home/Controller/PromoteController.class.php index 5b5780783..a7ce79580 100644 --- a/Application/Home/Controller/PromoteController.class.php +++ b/Application/Home/Controller/PromoteController.class.php @@ -25,7 +25,7 @@ use Home\Model\UserPlayModel; use Home\Model\PromoteModel; use Base\Service\PromoteService; use Base\Service\ApplyService; - +use Base\Repository\SpendRepository; use Org\RedisSDK\Redis; /** @@ -34,6 +34,15 @@ use Org\RedisSDK\Redis; */ class PromoteController extends BaseController { + public $spendRepository; + + protected function _initialize() + { + parent::_initialize(); + $this->spendRepository = new SpendRepository(); + } + + //系统首页 public function index($p = 1) { @@ -132,11 +141,6 @@ class PromoteController extends BaseController $promoteId = array(get_pid()); - //计算当日用户充值数据 -// $map['_string'] = "promote_id = {$promote_id} or tab_promote.parent_id = {$promote_id} or tab_promote.grand_id = {$promote_id} "; - //计算当日用户充值数据 -// $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, []); @@ -169,22 +173,6 @@ class PromoteController extends BaseController ->order('count desc, register_time') ->find(); -// $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') -// ->where($map) -// ->group('promote_id1') -// ->having('promote_id != 0') -// ->order('count desc,register_time') -// ->find(); -// var_dump($data);die(); -// echo M('promote', '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); @@ -194,8 +182,6 @@ class PromoteController extends BaseController //计算昨天用户的统计数据,当日用户充值数据 $pay_time = " between {$yesterday_start} and {$yesterday_end}"; $createTime = ['between', array($yesterday_start, $yesterday_end - 1)]; -// $yesterdaySpendData = $this->caculateSpend($pay_time, []); -// var_dump($yesterdaySpendData);die(); $todayAddSpendData = $this->caculateSpend($pay_time, [], [], 1); @@ -217,9 +203,7 @@ class PromoteController extends BaseController $today_total_money = $this->pay_total(1, 0, $promoteId); $this->assign('data', $data); -// $this->assign('yesterdayData',$yesterdayData); $this->assign('spendData', $spendData); -// $this->assign('yesterdaySpendData', $yesterdaySpendData); $this->assign('todayAddSpendData', $todayAddSpendData); $this->assign('mounthAddSpendData', $mounthAddSpendData); @@ -424,6 +408,9 @@ class PromoteController extends BaseController $promoteIds[] = $promoteId; $map['promote_id'] = ['IN', $promoteIds]; + + $map = $this->spendRepository->withIsCheck($map); + if (in_array($type, [1, 2])) { $whereUser['promote_id'] = $map['promote_id']; if ($type == 1) { @@ -508,7 +495,7 @@ class PromoteController extends BaseController } $where['spend.promote_id'] = array('in', $promoteId); $where['spend.pay_status'] = 1; - $where['spend.is_check'] = array('NEQ', 2); + $where = $this->spendRepository->withIsCheck($where, 'spend.is_check'); switch ($type) { case 1: { // 今天 diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php index f93a204db..eb9959bf3 100644 --- a/Application/Home/Controller/QueryController.class.php +++ b/Application/Home/Controller/QueryController.class.php @@ -17,6 +17,15 @@ use Base\Repository\GameRepository; */ class QueryController extends BaseController { + + public $spendRepository; + + protected function _initialize() + { + parent::_initialize(); + $this->spendRepository = new SpendRepository(); + } + public static $payWay = [ -1 => '绑币', 0 => '平台币', @@ -127,6 +136,8 @@ class QueryController extends BaseController if ($payedBegTime && $payedEndTime) { $map['tab_spend.payed_time'] = ['between', [$payedBegTime, $payedEndTime - 1]]; } + + $map = $this->spendRepository->withIsCheck($map, 'tab_spend.is_check'); $data = []; $count = 0; @@ -1976,6 +1987,10 @@ class QueryController extends BaseController $spendMap['_string'] = 'today.user_id = s.user_id and today.game_id = s.game_id and today.server_id = s.server_id and today.game_player_id = s.game_player_id and today.promote_id = s.promote_id'; $spendMap['today.pay_status'] = 1; $spendMap['today.pay_time'] = ['between', [$nowTime, $nowTimeEnd]]; + + $map = $this->spendRepository->withIsCheck($map, 's.is_check'); + $spendMap = $this->spendRepository->withIsCheck($spendMap, 'today.is_check'); + $fieldToday = M('spend', 'tab_')->alias('today') ->field('sum(pay_amount) as recharge_cost_today') ->where($spendMap) @@ -3027,6 +3042,8 @@ class QueryController extends BaseController $map['a.server_id'] = $serverId; } + $spendMap = $this->spendRepository->withIsCheck($spendMap); + $spendSubSql = M('spend', 'tab_')->field(['game_id', 'server_id', 'sum(pay_amount) amount'])->where($spendMap)->group('game_id, server_id')->select(false); $roleSubSql = M('user_play_info', 'tab_')->field(['game_id', 'server_id', 'count(*) count'])->where($roleMap)->group('game_id, server_id')->select(false); diff --git a/Application/Home/View/default/Public/promote_base.html b/Application/Home/View/default/Public/promote_base.html index 141be6e01..2a3b6e503 100644 --- a/Application/Home/View/default/Public/promote_base.html +++ b/Application/Home/View/default/Public/promote_base.html @@ -36,19 +36,30 @@ - +