From f034698dbcb02fed72f9a20d20a04a2e4a543b54 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Mon, 14 Dec 2020 10:16:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=A4=9A=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Common/function.php | 9 ++++ Application/Admin/Conf/config.php | 8 +++- .../Controller/SpendController.class.php | 22 ++++----- Application/Admin/Model/SpendModel.class.php | 4 +- Application/Admin/View/Spend/lists.html | 8 +--- jbc.php | 48 +++++++++++++++++++ 6 files changed, 77 insertions(+), 22 deletions(-) create mode 100644 jbc.php diff --git a/Application/Admin/Common/function.php b/Application/Admin/Common/function.php index e50a1665e..085401c84 100644 --- a/Application/Admin/Common/function.php +++ b/Application/Admin/Common/function.php @@ -1057,3 +1057,12 @@ function showNumPercent($num) } } +//优化子站点实例化方法 +function SM($name='', $tablePrefix='tab_') +{ + $tableName = strtolower($tablePrefix.$name); + if(in_array($tableName,C('SUBSITE_TABLE')) && IS_SUBSITE){ + return M($name, $tablePrefix,SUBSITE_DB); + } + return M($name, $tablePrefix); +} diff --git a/Application/Admin/Conf/config.php b/Application/Admin/Conf/config.php index e45f7d8cc..ff9f5af47 100644 --- a/Application/Admin/Conf/config.php +++ b/Application/Admin/Conf/config.php @@ -103,7 +103,7 @@ return array( /* SESSION 和 COOKIE 配置 */ 'SESSION_PREFIX' => 'onethink_admin', //session前缀 - 'SESSION_COOKIE_PATH' => '/admin.php', + 'SESSION_COOKIE_PATH' => '/'.SUBSITE_INDEX, 'COOKIE_PREFIX' => 'onethink_admin_', // Cookie前缀 避免冲突 'VAR_SESSION_ID' => 'session_id', //修复uploadify插件无法传递session_id的bug @@ -113,5 +113,9 @@ return array( 'TMPL_EXCEPTION_FILE' => MODULE_PATH.'View/Public/exception.html',// 异常页面的模板文件 /*默认公司名称*/ 'DEFAULT_COMPANY'=>"海南万盟天下科技有限公司", - 'OFFICIEL_CHANNEL'=>"江息网络" + 'OFFICIEL_CHANNEL'=>"江息网络", + /*分库的表格*/ + 'SUBSITE_TABLE'=>[ + "tab_spend" + ] ); \ No newline at end of file diff --git a/Application/Admin/Controller/SpendController.class.php b/Application/Admin/Controller/SpendController.class.php index 15416f9c9..a9fca7d3e 100644 --- a/Application/Admin/Controller/SpendController.class.php +++ b/Application/Admin/Controller/SpendController.class.php @@ -137,23 +137,21 @@ class SpendController extends ThinkController $this->checkListOrCountAuthRestMap($map,["extend", "pay_order_number", "user_account"]); $map1 = $map; $map1['pay_status'] = 1; - $total = null_to_0(D(self::model_name)->where($map1)->sum('pay_amount')); - $ttotal = null_to_0(D(self::model_name)->where('pay_time' . total(1))->where(array('pay_status' => 1))->sum('pay_amount')); - $ytotal = null_to_0(D(self::model_name)->where('pay_time' . total(5))->where(array('pay_status' => 1))->sum('pay_amount')); + $total = null_to_0(SM(self::model_name)->where($map1)->sum('pay_amount')); $this->assign('total', $total); - $this->assign('ttotal', $ttotal); - $this->assign('ytotal', $ytotal); $this->meta_title = $this->m_title = '游戏充值'; $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Spend/lists', 'status' => 1])->find()); - - $data = D(self::model_name)->lists($_GET["p"], $map, $order); - $adminUsernameList = getAdminUsernameList(array_column($data['data'], 'market_admin_id')); - foreach ($data['data'] as $key=>&$value ) { - ($value['promote_account']=='官方渠道')?($value['promote_account']=C('OFFICIEL_CHANNEL')):''; - $value['market_admin_username'] = $adminUsernameList[$value['market_admin_id']] ?? '无'; - $value['is_check_str'] = D(self::model_name)::IsCheckStr[$value['is_check']]; + $data = D(self::model_name)->lists($_GET["p"], $map, $order); + if(!empty($data['data'])){ + $adminUsernameList = getAdminUsernameList(array_column($data['data'], 'market_admin_id')); + foreach ($data['data'] as $key=>&$value ) { + ($value['promote_account']=='官方渠道')?($value['promote_account']=C('OFFICIEL_CHANNEL')):''; + $value['market_admin_username'] = $adminUsernameList[$value['market_admin_id']] ?? '无'; + $value['is_check_str'] = D(self::model_name)::IsCheckStr[$value['is_check']]; + } } + $this->assign('showMarketAdmin', session('user_auth')['show_market_admin']); $this->assign('showPromote', session('user_auth')['show_promote']); $this->assign('isMarketAdmin', $isMarketAdmin); diff --git a/Application/Admin/Model/SpendModel.class.php b/Application/Admin/Model/SpendModel.class.php index 3153c7efc..40204893b 100644 --- a/Application/Admin/Model/SpendModel.class.php +++ b/Application/Admin/Model/SpendModel.class.php @@ -796,12 +796,12 @@ class SpendModel extends Model } else { $row = 10; } - $list = $this + $list = $this->db(1) ->where($map) ->page($page, $row) ->order($order ? $order : 'pay_time desc') ->select(); - $count = $this->where($map)->count(); + $count = $this->db(1)->where($map)->count(); $data['data'] = $list; $page = set_pagination($count, $row); if ($page) { diff --git a/Application/Admin/View/Spend/lists.html b/Application/Admin/View/Spend/lists.html index 1ce4f4ede..b0c5c84ef 100644 --- a/Application/Admin/View/Spend/lists.html +++ b/Application/Admin/View/Spend/lists.html @@ -377,14 +377,10 @@ 汇总 当页充值:{:null_to_0(array_sum(array_column(array_status2value('pay_status','',$list_data),'pay_amount')))} - - + 累计充值:{$total}(此处只汇总充值成功的订单) - + diff --git a/jbc.php b/jbc.php new file mode 100644 index 000000000..f4f81d45b --- /dev/null +++ b/jbc.php @@ -0,0 +1,48 @@ + 5.3.0 !'); + + +/** + * 系统调试设置 + * 项目正式部署后请设置为false + */ +define('APP_DEBUG', true ); +define('BIND_MODULE','Admin'); +define('ROOTTT',dirname(__FILE__).'/'); +define('ROOTTTTT',dirname(__FILE__)); +define('FONTS',dirname(__FILE__).'/Public/Admin/fonts/'); +/** + * 应用目录设置 + * 安全期间,建议安装调试完成后移动到非WEB目录 + */ +define ( 'APP_PATH', './Application/' ); + +if(!is_file(APP_PATH . 'User/Conf/config.php')){ + header('Location: ./install.php'); + exit; +} + +/** + * 缓存目录设置 + * 此目录必须可写,建议移动到非WEB目录 + */ +define ( 'RUNTIME_PATH', './Runtime/' ); +/** + * 项目配置 + */ +$JBC_DB_CONFIG = include_once APP_PATH."/Common/Conf/env.php"; +$JBC_DB_CONFIG = $JBC_DB_CONFIG['JBC_DB_CONFIG']; +define ( 'IS_SUBSITE', TRUE); +define ( 'SUBSITE_NAME', "jbc"); +define ( 'SUBSITE_DB', $JBC_DB_CONFIG ); +define ( 'SUBSITE_INDEX', "jbc.php" );//子站点路口,影响session + +/** + * 引入核心入口 + * ThinkPHP亦可移动到WEB以外的目录 + */ +require './ThinkPHP/ThinkPHP.php'; \ No newline at end of file