diff --git a/Application/Admin/Controller/PaymentMerchantController.class.php b/Application/Admin/Controller/PaymentMerchantController.class.php index be98bf85f..0e4ec3abf 100644 --- a/Application/Admin/Controller/PaymentMerchantController.class.php +++ b/Application/Admin/Controller/PaymentMerchantController.class.php @@ -8,6 +8,7 @@ use Base\Service\MerchantMainService; use Base\Service\PaymentRuleService; use Base\Service\PromoteCompanyService; use Base\Service\GameService; +use Exception; use Think\Model; /** @@ -857,4 +858,107 @@ class PaymentMerchantController extends ThinkController ] ]); } + + public function editMaster() + { + $id = I('id', 0); + + $rule = null; + if ($id > 0) { + $rule = M('game_master_merchant_rule', 'tab_')->where(['id' => $id])->find(); + if (empty($rule)) { + $this->error('记录不存在'); + } + } + + $gameService = new GameService(); + $games = $gameService->getBaseGames(); + + $this->assign('games', $games); + $this->assign('rule', $rule); + $this->display('masterForm'); + } + + public function saveMasterRule() + { + try { + $params = I('post.'); + $service = new PaymentRuleService(); + $service->saveGameMasterMerchantRule($params); + + $this->ajaxReturn([ + 'status' => 1, + 'message' => '成功', + ]); + + } catch (Exception $e) { + $this->ajaxReturn([ + 'status' => 0, + 'message' => $e->getMessage(), + ]); + } + } + + public function deleteMasterRule() + { + $id = I('post.id', 0); + M('game_master_merchant_rule', 'tab_')->where(['id' => $id])->delete(); + $this->ajaxReturn([ + 'status' => 1, + 'message' => '删除成功', + ]); + } + + public function masterRules() + { + $page = I('p', 1); + $row = I('row', 10); + $baseGameId = I('base_game_id', 0); + $startedAt = I('started_at', '1970-01-01'); + $endedAt = I('ended_at', '9999-01-01'); + + $conditions = []; + if ($baseGameId != 0) { + $conditions['base_game_id'] = $baseGameId; + } + + $conditions['update_time'] = ['between', [strtotime($startedAt . ' 00:00:00'), strtotime($endedAt . ' 23:59:59')]]; + + $query = M('game_master_merchant_rule', 'tab_')->where($conditions); + $countQuery = clone $query; + + $items = $query->order('id desc')->page($page, $row)->select(); + $count = $countQuery->count(); + + $admins = M('ucenter_member', 'sys_')->field(['id', 'username'])->select(); + $admins = index_by_column('id', $admins); + + $records = []; + foreach ($items as $item) { + $records[] = [ + 'id' => $item['id'], + 'base_game_id' => $item['base_game_id'], + 'base_game_name' => $item['base_game_name'], + 'is_first_pay' => $item['is_first_pay'], + 'max_times' => $item['max_times'], + 'max_pay_amount' => $item['max_pay_amount'], + 'admin_username' => $admins[$item['admin_id']]['username'], + 'update_time' => date('Y-m-d H:i:s', $item['update_time']), + ]; + } + + + $page = set_pagination($count, $row); + if($page) { + $this->assign('_page', $page); + } + + $gameService = new GameService(); + $games = $gameService->getBaseGames(); + + $this->assign('games', $games); + $this->assign('records', $records); + $this->assign('admins', $admins); + $this->display(); + } } diff --git a/Application/Admin/View/PaymentMerchant/masterForm.html b/Application/Admin/View/PaymentMerchant/masterForm.html new file mode 100644 index 000000000..5a82744a6 --- /dev/null +++ b/Application/Admin/View/PaymentMerchant/masterForm.html @@ -0,0 +1,162 @@ + + +
+ + +